Twist endings should be good. I know this is a contentious position, but I'm sticking by it, dammit.
There are three key components to a good twist ending. They are that it should be unexpected, and it should force the audience to reevaluate what they've just been shown, and that reevaluation should be as good as or better than what they just watched.
Take a look at the twist ending in Psycho, where we discover that the mother has been dead all along and that her son Norman has been committing murders. This is unexpected, because nobody really expected Norman to dress up like an old woman, because who the hell would expect that? This forces the audience to reevaluate what they've been shown, as every scene where the "mother" had been shown killing someone now has to be mentally replaced with a guy wearing a wig and a dress. And finally, this reevaluation makes the movie much, much creepier than just an old woman killing people, as we are shown the depth of Norman's psychosis.
An example of a bad twist ending would be The Village. Towards the end, we discover that what was thought to be a small town in the 19th century is actually part of a nature reserve in the modern era. This is unexpected (if you had no prior knowledge of the director), this causes us to reevaluate the movie, but the problem is that this reevaluation has no bearing on the story whatsoever. It is a twist without consequences.
Les Diaboliques has a twist ending that is actually somehow worse than the one in The Village, in that instead of the reevaluation being utterly useless, it is also nonsensical. In this film, a wife and a mistress team to murder a detestable husband. They lure him to a tiny village, drug and drown him, bring the body back to his place of work, and leave it in a swimming pool to be found later. After a few days of the body not being discovered, they drain the pool and find the body missing. Afterward, the wife has a nervous breakdown. One night, she sees the image of the dead husband in her bathtub, has a heart attack and dies.
The twist ending is revealed right after the she dies, when we see that the husband was alive all along, working with the mistress to scare the wife to death. This is dumb. At no point in moving the body -- wrapping it up, loading it into the car, unloading it from the car, dumping it into the pool -- did the wife see him breathe or move, nor felt his body heat. Also, this means that he somehow survived being left submerged in water, like a dead body, and didn't actually drown. And to what effect? To trick the wife into thinking the husband died so that they could scare her to death? If the original murder plan for the husband was sufficient, why not just do that to her? And this serves as a really shitty alibi for the police, who knew that the husband was missing for a few days. Sir, where have you been for the past few days? Why is your wife dead under suspicious circumstances with a clear motive on your part? Why were you sitting in a bathtub fully clothed in the same room where your wife just died? This shit doesn't make any sense.
Twist endings can be great, but they can also be really, really fucking awful.