Deus ex machina

A "deus ex machina" was, according to the Tenth Doctor, a convenient ending where the solution comes out of nowhere, without being set up ahead of time.

After he saved Lobus Caecilius and his family from being killed by the eruption of Mount Vesuvius, Donna Noble pondered if this made the Doctor a deux ex machina, reasoning that he was a godlike being who had a machine. The Doctor corrected her, saying that nobody ever used the phrase correctly, with it commonly being used on the internet to refer to "an ending I didn't like". (PROSE: The Fires of Pompeii)

Behind the scenes
The phrase is Latin for "god out of the machine", hence Donna's misinterpretation of the phrase.