Okay, lots of good comments on building tension. My comment is focused on motivation. It is very hard to get an audience to like a film where all the protagonists die. Many screened films have had their endings re-written before they are released because of audience complaints.
Now that doesn't mean it needs to be a Pollyana ending. What is often done is the protagonists sacrifice themselves for a higher purpose. Often that is tied into the cause of the tension--saving the kid, kitten, city, world, whatever. This is specifically when you kill the main characters whom the audience has been following. The deaths need to serve a greater purpose for the viewer to feel satisfied. It may seem crassly commercial but after 9/11, the Oklahoma City bombing, audiences are easily polarized. Build your tension, blow'em up, then follow up with the kid, kitten, etc. who are alive. Give them a brief memorial.
I was once told, "Kill off your protagonist at your own peril." Well, I don't totally buy that. But most successful movies do preserve a "karmic balance" in the ending. It's a triumph over adversity that the audience carries away with them. Just my two cents.