Creative Writing/Fiction technique/Deus Ex Machina

Deus ex Machina is a technique used primarily in drama but not limited to the stage; translated, it means: "God out of the Machine". A deus ex machina ending to a play or book is when the plot builds up so hopelessly and dramatically that it seems that it cannot be resolved by any means, only for a sudden improbably solution to appear.