There are a couple things to keep in mind about writing endings. One is that they must be prepared for properly. The other is that they can't be entirely expected.
These two things can actually work against one another, because if you've prepared throughout your manuscript for a particular ending, people will generally expect it. You then need to defeat their expectations. So if you reach the ending and experience reader protest, then there are two possible sources for a solution.
1. Change the preparation
2. Change the ending to beat the expectations
I've done #1 quite a lot: discovered that readers felt an ending I wrote was unsupported - that is to say, not given a proper foundation - in what came before. The solution to this problem is to go back and build a proper foundation in the earlier material. Set up the right convergence of characters and motives, set up the proper world knowledge, etc.
I've also done #2. When my plot gives a person a choice of two options - either the protagonist gets one thing or gets another - there can be a different kind of problem. Sometimes the reader can feel unsatisfied with either option, because they saw the choice coming a mile away and neither one answers the story problem particularly well. In that case, you can do one of two things: satisfy yourself with a sense of ambiguity, or look for a third alternative.
Naturally, any solution you choose does have to fit well with the preparation. One of the things that is most important to me is that the solution be the best one for the protagonist's particular character. An ambiguous ending requires both options to be just about equal in attractiveness from this point of view. And any third alternative has to have both a benefit and a price. If the protagonist has wanted one particular deal through the whole story, and at the end must decide to try for another outcome, there must be a big risk involved, and possibly a sacrifice. If your character gets to have it both ways too easily, then readers will feel like it was a cop-out, that all the difficult lead-in was let down at the end. And you don't want that either.
This stuff is very difficult - not only coming up with the options but deciding which one will serve the story best.
A couple of examples from my own work.
I had a big complicated solution planned for a novel which involved negotiating with multiple parties and then confronting a single heavily recalcitrant party to use the masses to sway his opinion. When I got there, it seemed foregone. So I decided to go back and set up the expectation for a bimodal (one-or-the-other) solution. The protagonists decide the only way to reach this recalcitrant person they must convince is to bring him someone he knows, through great peril, to convince him. Then readers ask, "Will the convincing person arrive or not?" They believe his arrival is the only solution, and then when he doesn't arrive, they find the planned ending much more unexpected (and hopefully persuasive - I'm still working on it).
In another story, I had the hero striving for a goal that he would either get or not. When I wrote it with him achieving the goal, all the difficulties that I'd set up for him seemed flat. Of course he was going to succeed, ho, hum. And anyway, readers weren't at all sure that the deal he got was the best one for him, because it came with a lot of strings. So that time I backed off and tried to get to the bottom of his motive. This is what my husband calls trying to find the real goal of the negotiation (in a business context): not looking at the offers that the two parties have put on the table, but looking past that to the actual desired outcome, and trying to find a way to satisfy that outcome independently of the existing offers. When I did this, I found a much more satisfying ending for the story.
Right now I'm in another quandary situation, looking at the ending of a story and trying to evaluate the building blocks, the lead-in, the characters' needs, and what kinds of options I have. It's never easy, but if I can manage to think about it clearly, I'll have a better story on my hands.
Have any of you had an experience like this? If you have, I'd love to hear.