The PM said he would prefer to get a deal but the UK must leave the EU by 31 October “whatever the circumstances”.