A plot twist is a literary technique that introduces a radical change in the direction or expected outcome of the plot in a work of fiction. When it happens near the end of a story, it is known as a twist ending or surprise ending. It may change the audience's perception of the preceding events, or introduce a new conflict that places it in a different context. A plot twist may be foreshadowed, to prepare the audience to accept it, but it usually comes with some element of surprise.
https://en.wikipedia.org/wiki/Plot_twist