After the brexit referendum results came in, there has been a lot of talk about Article 50 of the Treaty on European Union:
Any Member State may decide to withdraw from the Union in accordance with its own constitutional requirements.
A Member State which decides to withdraw shall notify the European Council of its intention. In the light of the guidelines provided by the European Council, the Union shall negotiate and conclude an agreement with that State, setting out the arrangements for its withdrawal, taking account of the framework for its future relationship with the Union. That agreement shall be negotiated in accordance with Article 218(3) of the Treaty on the Functioning of the European Union. It shall be concluded on behalf of the Union by the Council, acting by a qualified majority, after obtaining the consent of the European Parliament.
The Treaties shall cease to apply to the State in question from the date of entry into force of the withdrawal agreement or, failing that, two years after the notification referred to in paragraph 2, unless the European Council, in agreement with the Member State concerned, unanimously decides to extend this period.
It is possible to imagine a scenario where the UK invoke Article 50, but then change their mind and don't want to leave (e.g. because the negotiated deal was not good enough, or because of new elections). It is also reasonable to believe that the EU would be happy to keep the UK.
From the news I am given the impression that the UK would have to leave if they invoked Article 50 even if both the EU and the UK agreed that it would be better if they stayed. Is that so?