Just as a friendly warning, this entry contains minor spoilers about Battlestar Galactica and The Sixth Sense. If you were going to watch either of these you probably have already, but just in case, there you go. Even if you haven't seen both of these, the entry will still make sense.
After numerous attempts at watching Battlestar Galactica (mostly looking for a science fiction show hoping it would turn into either Firefly or season one of Heroes) I'm finally through to the last season, and while I have to say that for the most part I can't really recommend the show, it's taught me (or highlighted) some interesting stuff about storytelling (mostly what not to do).
The thing that caught my attention most recently is the way the "twist ending" of Season 3 of Battlestar Galactica falls so flat, and why some twists work while others don't.
Basically, there are twelve Cylon (robots out to kill us, according to episode one) models that look human. At this point in the series seven of them are known, and the other five have not. Even the other Cylons don't know who they are, and they had been building that hype for awhile. At the end of season 3, we find out four of the missing five, who are all part of the human fleet and main members of the cast. (Every episode of season 4 will beg you to keep watching by reminding you one has yet to be revealed.)
Now, TV implausibilities aside (the hundreds or even thousands of things that would have happened in the lives of those characters that coincidentally guided them to where they are now) the reveal falls really flat for one big reason: We never saw it coming.
When you watch a movie like The Sixth Sense and discover at the end of the movie that he's been dead the whole time, it makes you go, "Oh, yeah..." because you likely didn't see it coming, but if you rewatch the movie, it seems really obvious.
Now, I accept that this is hard to pull off. But having your big reveal be too obvious is less of a danger than just never hinting at it. If you never hint at it at all, there's no "Oh, yeah..." moment that actually makes a person want to rewatch or reread or replay what you've created. It's just "Okay, sure, whatever." The audience feels cheated. The story no longer makes sense.
You can fool your audience. You can deceive, trick, bamboozle, baffle, and mock your audience. But when it's done, the audience has to see your story was leading up to that big reveal. Otherwise your entire story just falls flat. It's essentially the mystery writer's version of a deus ex machina. It's almost always a sign of poor writing.
A great twist ending is one of the holy grails of writing. It gets people talking about your work, gets them eager to go back and experience it again, and gets them looking more deeply at what you've created.... but you have to lead your audience there. If it comes out of nowhere like so many episodes of Scooby Doo (surprise, it was this guy you've never met before!), your readers will just be left saying "well, you got me. Thanks for wasting my time."