What is an unexpected ending to a sentence called?

A figure of speech involving a sentence with a surprise ending is called a “paraprosdokian.” Other terms include “surprise ending” or “twist.”

Paraprosdokian example: “The last thing I want to do is hurt you, but it’s still on my list.”