i kill off probably half of my main characters in the end. stephen king does it and tells you he's going to do it... every. single. time.
but i like to refer to movies because more people are apt to see them than read the same book. look at 'the godfather,' 'saving private ryan,' and 'gladiator.' killing off your protagonist is a time honoured way of rounding out a story. arthur and robin hood die, too. so does beowulf, eh? hell, even conan dies in the end. grimm fairy tales were hardly this PC slop we force-feed kids today. nothing wrong with tragedy in a story.
i wonder if there's any real way you can answer this question without a thousand examples. i guess some advice may be to, as always, try to avoid cliches. (i'm always amused at how some generic enemy soldier dies instantly from a tiny bit of schrapenel while the bullet-riddled body of the hero lingers on for six hours until spitting out what wisdom he's got to impart.)
i just try to handle their deaths as appropriately as possible. the last WIP i was working on i got bored and skipped to the very end, titling the chapter 'the deaths.' bear in mind it was planned to be at least a three book project with half of the story taking place in the 16th century. there was, though, an overall pathos to the story, so 'the deaths' come as no great surprise. it was also very appropriate because of the epic approach i took.
my current WIP's original incarnation had the hero die in the end. then i thought, nah, that's not what the book is about once i started writing it. somehow, and probably thankfully so, it turned from this regular story about a man out to destroy technology that hides the truth to the hero really being on a philosophical journey, the rest just being surface bullsiht. ironically, the rethought version is much sadder than had i killed him off, so maybe it's possible that there's an extreme more extreme than death, eh?
another movie that starts off with the hero already dead is 'casper.' kinda a sick idea if you ask me. to a certain extent, 'beetlejuice' and 'ghost.'