There are a ton of memes about authors killing characters. Principal and secondary characters. It doesn't matter inevitably, those are the characters, that as readers, we're overly attached to and it feels like our hearts are being ripped out of our chests when we read their deaths. Authors don't pull punches.
Honestly, as much as it hurts, the demise of a character is important. Hear me out. All of us experience the death of loved ones at some point in our lives. If no one ever dies in a book, it's not realistic. Sure, as readers, the point is to get away, but any writer will tell you that there has to be some reference to real life, otherwise nothing in the book will seem plausible. Absolutely, we all want to live in a world that's perfect and no one ever dies, that would be supreme, but we lost out on that deal when Adam and Eve sinned.
In my second book (spoilers!) one of my secondary characters dies. As the author, I love him dearly, but it made sense to the scene and the battle that was taking place. He will be missed, however, his legacy will live on in the hearts of the characters that do survive. I'll probably be pouring the vodka on the day that I write the scene. Even in my first draft it was gut wrenching to see him leave the cast. Maybe I should make a commemorative pin to preserve his memory. Too much?
So, the next time you get mad (hurt) by an author killing a character, I encourage you to take the time to see the overall picture. Usually, an author does not kill a character without purpose. Death, at least in stories, gives way to something better. Always look for the something better.