Deus ex machina
A deus ex machina is an ending or rescue produced by something outside the story's established logic — a power, character or coincidence that nothing preceding it has earned.
The phrase means god from the machine, and it is stage machinery: the crane that lowered a god onto the Greek stage to settle a plot the characters could not settle themselves. Aristotle objected to it in the Poetics on the grounds that the resolution should come from within the story.
The most useful thing to understand is that this is a complaint about setup, not about plausibility. A dragon arriving in the final chapter is not a deus ex machina if the book has been about dragons and that particular dragon owes the hero a favour. The fault is arrival without preparation.
The test is one question: who solved it? If the answer is not the protagonist, or a consequence of a choice the protagonist made earlier, the ending will feel hollow no matter how much happens in it.
There are two honest fixes. Plant the rescue much earlier so the reader has met it before they need it — see Chekhov's gun — or make the protagonist pay a real price to obtain it.