How did the UK avoid a no deal exit?

Britain has been given until October 31st to agree on terms for EU exit.