How we change what others think, feel, believe and do
The twist ending finishes the story in an unexpected way.
Thus people turn out to be what they previously seemed not to be, or events that are supposed to have happened turn out to have not happened as presumed.
The result may be that what was appearing to come to a neat conclusion ends on a cliffhanger.
The real hero of the story turns out to be the quiet sidekick who springs into action after the supposed hero leaves or is killed.
The villain's companion turns out to be an undercover cop and saves the day just as the villain seems to be getting away.
The monster, presumed dead, reappears just after the hero has 'saved the day' and left.
The use of a minor character appearing as a major role right at the end can be foreshadowed in movies when they person is played by a famous actor.
The twist may be hidden by a narrator who does not realize (or conceals) some critical aspect of the story.
The twist ending can be result in the Zeigarnik effect being invoked as people are left open and wanting to know what happens next. This may be used if you are planning on writing a sequel.
Eucatastrophe is a twist at the end by which a hero who appeared to be doomed is saved. Thus it is a kind of 'reverse catastrophe'. The term was originated by J.R.R. Tolkien, who used the principle near the end of Lord of the Rings to save Frodo and Sam from Mount Doom.