Prime minister has left the door open to the UK rejoining the EU