I recently finished "The Book of Heroes" by Miyuke Miyabe (Translated by the incredible Alexander O. Smith), and I adored the book. It's a perfect read for mid-grade all the way up to young adult, although I wouldn't class it as adult fiction like a lot of people. That's beside the point.
Without revealing too much of the storyline, it's all about a fifth-grade girl (Yuriko Morisaki) who has to save her brother from the evil and nasty King in Yellow (a classic figure in Chinese mythology that somehow leaked into the book and turned all kinds of evil.).
It had a good setup, unique characters, a good world--and then came the twist. Twist endings are good, but only to an extent. The end of "The Book of Heroes" teeters dangerously close to the line between a good twist and a sour turn of events--a twist of lemon versus sucking on the whole bloody thing. It can be a fine art to master, and it won't keep your book from getting published, necessarily, but keeping your plot twist lemony fresh instead puckertastic can't hurt, right?
Take "Archenemy" by Frank Beddor. It's the final book in The Looking Glass Wars trilogy, and the trilogy is quite wonderful, as I've espoused in the past. However, that twist ending was sour to me, and to the other fans I've talked to--it was a deus ex machina, which is a big no-no. If you find yourself having to write a deus ex machina to complete your plot arc, I can only say two things:
1: Try to find another way. The last thing you want to do is have your villain struck down by lightning, unless your hero summoned the lightning and struck down the villain him/herself.
2: If you can't find another way, fix it. Edit backwards and drop hints instead of springing something out of the blue for no apparent reason. It's just bad writing.
Now, go out and twist your lemons!