Coming up with a good ending for a short story or novel is either a fluid mindless process, when the subconscious provides one, or just about impossible, if the writer has to think it through then frame it in words that don't seem labored.
A great ending elevates the story - it's worth the effort to get it right. My current favorite is Samuel Beckett's "Dante and the Lobster" (in the collections "More Pricks than Kicks" and "I Can't Go On, I'll Go On") - read it! The story provides hilarious and vivid imagery as the reader makes the rounds of his day with the protagonist. All seems in keeping with the grim view he takes of life and his techniques for prolonging it with agonized ritual, including the funniest bit about toast I've ever read.
Then, the final sentence: "It is not."
In three words Beckett demolishes the reader's comfort and amusement.
It's shocking, it's profound. It makes you wonder "How did he do that?" and "Can I ever possibly do that?"
The best endings I've written have showed up in the wee hours, when part of my brain is conscious but the rest zoned out, and my subconscious has free rein to neatly wrap things up. But if I have to do more than tweak that final image, I'm doomed. It won't cooperate. Writing ten or twenty alternate endings doesn't seem to get me any closer.
Some people write from an outline, so they know going in, more-or-less how a story will end. Do they feel an inspirational thrill when they get there? Does the ending write itself, or was it already there, and the function of the story is to reach the point where it comes next?
I enjoy being amazed by my characters - their resilience, their senses of humor, their understanding in the face of disaster that there is a Next. And when we get to the end of a story, they help me bring all the loose ends together - there's something magical about it. I type but they dictate.
Part of an effective ending is keeping the reader on the hook. In "Ladder of Years", Anne Tyler doesn't resolve her protagonist's dilemma until the final page - you can't put down the novel if you care about her at all. But when a book fizzles and you don't get there, it's frustrating. Brian Hall's "I Should Be Extremely Happy in Your Company" about Lewis and Clark's expedition, goes on and on after the leaders return from westward exploration. I stopped reading with about fifty pages left - whether they lived happy or miserable lives afterwards didn't matter to me.
A good ending is the height of aesthetics, providing a summation of the story's conflicts and a direction the protagonist will go. When well done, this shifts the reader from the circumstances at hand to the universals beneath. When we're given a good ending we feel we've gained by reading the story - and when it's unsatisfying, we have that urge to hurl the book across the room - "I read all those pages for THAT!?"