The ending of a story must be satisfactory. Yes, a happy ending is essential to some genres and some stories but not all stories have a happy-ever-after ending. The last part of a story must lead a reader to say yes, I can see that's the way it had to end.
But there are things leading to the ending of a story. There is the black moment or the crisis. This is when one or both of the main characters believes all is lost. The hero or heroine feels they will never gain love. The detective believes the criminal will go free. That's the sort of emotion the black moment brings. Following this the character or character must come to a decision and see what changes must be made so they can attain their goal.
Some books are hard for a writer to end. The characters have become really alive and it's like saying goodbye to a friend. One way to solve this is to do a sequel. When I was writing The Quest For The White Jewel, the editor thought the ending was all right but wanted me to do a bit more. That was the moment when it hit me that the story wasn't complete. Though the White Jewel had been found there were other jewels without Holders and there were also some of the baddies still running around. That was when I started the second book and untimately there was a third.
Here's a bit about epilogues. I generally don't write them because the ending I've written satisfies me, In romances, especially, an epilogue is often used to show the hero and heroine really have managed the happy-ever-after. I'm not sure this is necessary.