One of my pet peeves is when an author/writer spends a lot of time building up a character just to kill them off. Sometimes it is necessary to the story and I understand that but some authors, Stephen King for instance, does it in every book. I'm not sure if it is a belief he has, a predilection to mayhem, or if he just gets sick of characters after spending so much time writing and kills them due to some perverse need (as his main character did in Misery) . It could also be that he relieves homicidal instincts that way but since I don't know Mr. King I won't hazard a guess as to that.
However, I think with many writers it isn't a conscious action. In my case, for instance, as much as I hate it happening I have started books knowing that a character won't make it to the end. In fact, in one of my projects, it was the death of a character in my head that started me to writing the book in the first place. I won't mention which book it was, because that might act as a spoiler.
In another book, I intended from the beginning that one of my characters would die because it was going to set up the next book in the series. However, when I got to that part I was surprised to learn that it didn't happen. I tried to kill them off but darn it, they refused to die and instead another much more minor character died instead.
To anyone that is not a writer that may seem strange or contrived, but I think most writers who do not work from a carefully plotted outline will understand.
When I am writing, I usually have a general direction that the book will go in, usually because it take a little "push" to get started. I can't sit down and have the words just start spilling out, it takes a while for me to warm up. However, once I get going the story and characters take on a life of their own and often go in directions that i hadn't imagined. Occasionally that results in a problem.
For instance, when I was writing Junebug and the Body the book twisted on me toward the end and I couldn't figure out how to make it work or a way to tie two different story lines together. For weeks/months the book just sat there, 90% completed and STUCK!!!
One day my family and I were travelling back from visiting my mother in Louisiana, my wife driving while I napped in the passenger seat. Suddenly and without any warning BOOM! the problem was resolved. An idea on how to wrap up burst into my mind and the first draft of the book was finished a day or so later. I'm not sure what prompted the revelation since I was dozing and not even consciously thinking about the book but sometimes that's the way it happens. The story wrote itself. I had to go back and make a few small changes to tie the new idea in but once I did it was over. Except for the editing of course.
I said all that to say this, try not to be too hard on us writers when a favorite of yours gets knocked off.
Sometimes we didn't do it.
They killed themselves.