Story structure
Deus ex machina
A plot device going back to Greek theater: a seemingly unsolvable problem is abruptly resolved by an unexpected and unlikely occurrence.
Deus ex machina (Latin for "god from the machine") is a plot device "in which a seemingly unsolvable problem in a story is suddenly or abruptly resolved by an unexpected and unlikely occurrence." In Greek and Roman theater the god was an actor lowered onto the stage by a crane, the mechane; Euripides used the convention to end more than half of his surviving tragedies. Criticism is as old as the device: Aristotle held that "the solutions of plots, too, should come about as a result of the plot itself, and not from a contrivance."
That is the craft charge against it: the ending is not earned by the story's own cause and effect, which damages internal logic and the audience's suspension of disbelief. It is Chekhov's gun run in reverse, a payoff with no setup. Serial writers are the most exposed, because a corner written across months of published chapters cannot be unwritten; plan the exit while laying the trap. Standard examples include the eagle rescue in The Lord of the Rings and the sudden bacterial deaths in The War of the Worlds.