Some genres are more likely to have a happy ending while others are not. Cozies almost always tie up neatly with things turning out well for the protagonist in the end. One never knows with sci-fi and fantasy (which I discovered is a big reason I love it so much), and horror almost never ends well. So it's clear that there are some genre-related expectations. Does that mean we have to follow them? Heck no, we're fiction writers after all. But it is good to be aware of what the industry may expect.
It took me a few books to realize I wasn't the one who got to decide how the ending turned out. This hit me when I came to the end of a fantasy trilogy and had no idea which decision I should have a particular character make. Then it hit me, it wasn't up to me, it was up to her. I allowed her to make the decision she would have made~true to her character~rather than force something else on her. That was the moment I knew happy endings weren't a necessity, staying true to the story and the characters, was.