Downer endings can be really effective when done well. Works like Brazil, 1984, Metamorphosis, Amadeus, A Scanner Darkly, The Man Who Fell to Earth, and (to an extent) Citizen Kane use their endings to nail the final point and leave a powerful lasting impression. Similarly, they can be an excellent way to give people nightmares by ending on a really chilling note, sort of like in The Thing, The Wicker Man (the original, obviously), System Shock 2, Slender: The Arrival, and the 'bad' ending to Amnesia. (Most video-games don't have downer endings, because dying during game-play is itself considered a mini-tragedy
Downer endings are much more difficult than uplifting endings, though sometimes positive endings can be unbearably whimsical (like Lord of the Rings and every single Steven Spielberg film). They are more difficult because downer endings can very easily be seen as a cheat. If you don't have a good reason for why the protagonist didn't make it, why he/she died alone and unloved, or why the plan failed then your going to annoy a lot of people. As jstudios said so excellently, it needs to fit the arc and tone.
This all being said, I really wish one of the villains would just shoot James Bond instead of comprising over-elaborate traps. Looking him in the eyes before placing a bullet in-between them would be just as satisfying as dumping him in your killer bee enclosure...