Ending-Spoilers ahoy below!
Basically, it's like a Deus ex Machina
, only EVIL. This is for when the author realizes, to his chargrin, that there's actually a chance that the heroes will wind up being HAPPY at the end of the story - and we can't have that, since True Art Is Angsty
. Enter a completely random and arbitrary event that makes sure that EVERYBODY, including the reader, is going to come away from the ending with a crushing depression. It can involve either entirely random events, or inexplicably turning somebody Too Stupid To Live
Mind, it IS possible to create a 'sad ending' without resorting to this - for example, in His Dark Materials, the very premise of the interdimentional travel ensures that Will and Lyra will end up sepparated by infinity. Taking away Lyra's compass-reading abilities was a bit of a "Kick 'em while they're down" moment, but it's really mostly irrelevant.
A textbook example of this is City Of Angels - after the angel has fallen to mortality in order to be with his love-interest, a truck just comes outta nowhere, for no reason whatsoever, and kills her. Just because.
Perdido Street Station brings out a Double-Barreled Demon Ex Machina
- first Lin's utterly ridiculous and unreasoned decision to turn around when EVERYBODY is yelling "Don't look behind you!!" and studiously turning their backs to it. Compounded by the Slake-Moth grabbing her and sucking the juice out the MOMENT she's hypnotized, even though Mr. Motley has, at that point, been hypnotized by it for several minutes at least - it just ignored him. And second, the out-of-the-blue arrival of Kar'uchai, and Isaac's unexplainable decision to betray Yag because of what she tells him. China Mieville couldn't allow even ONE character to come away from the story feeling the least bit happy...
I must admit, this trope is partially motivated by self-interest - I loathe 'bad endings' in general, and this type in particular - a list of examples would provide me with a nice list of movies and books to AVOID. >_<