The European Court of Justice has ruled that the UK can unilaterally revoke its withdrawal from the EU.