MPs have voted to ensure the UK cannot crash out of Europe without an agreement in place with Brussels.