Well, I don't like my readers to get too complacent so I think that there have to be some sad endings or they will always expect good ones. It's certainly true that I don't give my readers an easy ride. There is plenty of angst and torture in the body of pretty much all of my stories and there are a couple with tragic endings. However, my sad endings are always led up to, in that they are not sudden and out of the blue and, I think, they are bitter sweet in that they leave readers sad but uplifted in some way.
I don't know if I would suddenly kill off a major character at the end... or in the middle of a story. Maybe I should try it and see what happens, although I think I might be hung.
Personally I don't have a problem with a character I have invested in dying in the middle of a story with something after to pull me on. And I don't mind death at the end of a story as long as it has meaning and it leaves me with something other than a sour taste in my mouth.
Rilbur's 'Guardians' is a fabulous example
I suppose the test is... does it feel right, is it significant for the story. I suppose it's like sex ... in fact death and sex go together well in my mind... if it's gratuitous it turns me off but if its an integral part of the story and 'fits' it's just fine.