It follows a marathon EU summit in Brussels – just two days before the UK would have crashed out.