A great ending to a great story often ties up loose ends. It gives a sense of closure to the characters' arcs. For example, in 'The Lord of the Rings', the destruction of the One Ring and the return of peace to Middle - earth is a great ending. It resolves the main conflict and allows the characters to move on in a satisfying way.
Surprise can be a key element. A plot twist at the end that still makes sense within the context of the story can be really engaging. Like in 'The Sixth Sense', the revelation at the end completely changes the way you view the whole movie, but looking back, all the clues were there. It makes the story memorable.
A great ending also reflects on the themes of the story. If the story is about love and sacrifice, the ending might show how those concepts have changed the characters. Take 'Romeo and Juliet'. Their deaths are tragic but also show the extreme nature of their love and the cost of the feud between their families. It's an ending that makes you think about the themes long after you've finished the story.