I’ve posted before about while I prefer happy endings, I can deal with tragic ones as long as they are not done as pure “shock value”. What I don’t care for is the bad guys winning. We get enough of that in real life. So if a good person is killed off while doing away with a bad one (or more), that’s a type of sacrifice that’s been around since we started killing each other. In other cases, when main characters are older or in a terminal state, not pulling through isn’t unexpected.
Shifting over though from characters dying, the romantic relationships that don’t always end with the ones getting together you expect is also okay as long as it’s handled logically. A favorite twist is they come to the realization they aren’t right for each other, yet there is someone else waiting in the proverbial wings. Occasionally, as in a book I finished not long ago, of the three couples involved; two wound up with different individuals and the female half of the third couple wound up with no one, but it was because she came to understand she had to work through some deep personal issues before she would be ready for the right kind of relationship.
It was like in my first novel where the editor came back to me and said, “Look, you can stay with the mega-happy ending, but I’d like you to reconsider.” I thought it through and decided she was correct. It was still happy, although shaded with poignant. I have only ever changed one other ending. I was hard over at first about leaving it as was and then again, stepped back and considered the editor’s rationale. In that case, I made it happier than I planned and it worked, too.