The writer J. R. R. Tolkien coined the word by affixing the Greek prefix eu, (meaning good), to the word catastrophe. This means sudden turn of events at the end of a story which ensures that the protagonist does not meet some terrible, impending, and very plausible and probable doom,
Peripetia is a similar term which means a sudden reversal of fortune or change in circumstances, especially in reference to fictional narrative,
It looked like the hero was doomed until; a eucatastrophe and he was saved!
I fully expected a eucatastrophe, but in the climax of the movie, The Departed, almost everybody dies