Over the years, I've known writers who hated their lead characters, often the consequence of spending too much time with them, dealing with their problems, living in their heads. Who can blame us for occasionally sending one not just to The End but to their end?
How not to kill your protagonist: Anthony Adverse. After suffering through over a thousand of pages of emotional agony and hairs-breadth escapes, the hero settles down with his beloved son, you sigh with contentment...then Adverse dies pointlessly out in Texas. Ending the book this way breaks the delicate trust an author works to build with the reader. Of course, it can run the other way. If George R.R. Martin wanted to wreck his readers' trust, he'd create some charming, loveable character and have him or her wind up on the top of the heap instead of under it.
Though people often take the attitude that only horrors can be realistic, it is dangerous to shatter the reader's trust by leaving nothing salvageable from the wreckage. Especially if you hope that the reader will buy other works from you. I'm not saying that every book has to have the stereotypical Happily Ever After but the sudden death of your foremost character without any kind of fore-warning or even a higher feeling is a good way to have your book turned into an airborne projectile.
So how do you kill your protagonist?
Drink to Yesterday by the duo known as Manning Coles starts out with an inquest and a debate over suicide versus death by misadventure. You think at first that this is just a vintage British mystery. But as the book progresses, we find ourselves examining how a young man goes from being a thoroughly nice British schoolboy to a cunning and ruthless spy. It's WWI and Michael Kingston has been recruited into Military Intelligence by his former language master, Tommy Hambledon. Together they go to Germany. They make mistakes and have triumphs, both pure and poisoned. Slowly as the book progresses, we learn who it is lies dead at the beginning of the book and realize it is the only suitable ending for the character.
This book, and its sequel, Toast to Tomorrow, are two of the finest examples of how to write about dark material without gratuitously wallowing in despair that I have ever read. Though the books poignantly describe the misery of Germany at the end of WWI and even the rise of Nazism, there is always a feeling expressed that life is worth the living. These books, and the manifold sequels that Manning Coles wrote during the 1940's and 1950's, were a revelation to me.
I have always been one to look on the bleak side of things and so much of the media we consume encourages this view. No one has noble motives, no one ever gives from a full heart, everyone is a schemer and a liar. In James Bond, villains are one-dimensional and are killed with no more notice than a poor death-centric pun tossed after their corpse. Reality TV seems to exist only to show the nasty side of human nature. Some days the only good we see is a Cat GIF. Manning Coles isn't like that. Sometimes characters die that we would rather have live. But our very wish for them to live shows how Manning Coles can give a vivacity to even quite a minor character and to speak to the shared humanity in all of us. Even his most vicious spies are still recognizably human, with all the drives, loves, and mistakes that entails. That is a good lesson to take away from any book, let alone one that seems like nothing more than a standard spy novel.
I had read many funny books and many dark books but never ones that blended the two with such skill. Sometimes, yes, they slide a bit farther into slapstick than I might like, but they are British after all. Many people think 'soldier slapping officer with fish' when they think of 'British humor' but there's a humor that goes deeper. A frame of mind that accepts that bad things happen, often to good people, but that this is by no means the full tale to be told. I've tried to adopt that ideal not only into my own writing, but into my own life.