Stories are like puzzles. You start by outlining the whole thing, than add one piece after the other, taking care that the new pieces fit the work you have already created. The ending of a story is the last piece you insert into your puzzle: It completes the picture, and only when it is in place will you be able to understand the story in its entirety. Conversely, the last piece of your puzzle -- your ending -- is so strongly confined by what you have already laid out that there's hardly any room left for eventualities. Try to cram in a piece that does not fit and you will ruin the entire puzzle.
Observe that this has nothing to do with the puzzle designer wanting something else than you, the puzzle solver. Because it is a puzzle and unless it is broken or you mixed it up with another puzzle or you lost a piece, the last piece will fit in. Of course, you are free to not like the puzzle once it is finished. You are allowed to critize what you see and think: "I would have preferred another picture". But this has nothing to do with the puzzle per se -- rather, it is because your taste is different from the taste of the puzzle designer.
I believe (imagine that word underlined twice, because I honestly cannot prove this claim) that stories are to a degree independent of the storyteller. Stories are abstract entities that are just there. You, as the storyteller, can not create them -- you discover them. Because of this, what storytelling really boils down to for me is honesty. You have your idea, you have your characters, and while writing down your story or telling it in any other way, you discover it, piece by piece, like a puzzle, until it is complete. Unfortunately, there is no easy way to tell when a story is complete. To me, it's an abstract feeling that all the elements fit together and that the story I tell is as independent as possible from what I want for the story. Only when I feel that everything that happens in the story is necessary, natural to the characters, and a consequence of what has happened before, does the story feel right. As long as I read a scene, frown and think: "Something else could happen here", I'm not done discovering the story. (And the fun thing is: When my test readers critize my work, it's usually because of things that I had not fully discovered yet.) This act of discovering of what really happens in your story is all about honesty -- you need to be honest to yourself and to your characters. This can be very hard, because you do have a vision for your story and sometimes this vision blinds you for the truth of your story. But my experience is that not seeking this inherent truth of a story and settling for something that you forced onto the story leads to unconvincing stories in the end(1).
And now: The readers. I think, this is very simple. Readers are extremely good at detecting inconsistencies in your story. In fact, they are much better at it than you are, because they do not share your story vision and hence can not be blinded by it. Consequently, when you write something that is not honest to your story, your readers will find it, and they will not like it.
This, however, is independent of the point in the story at which the dishonesty occurs. It can be the ending, but it need not be.
Side note: What does "writing for an audience" actually mean? Does it mean to write a book that sells well to a specific target audience? If this is the case, "writing for an audience" is independent of the ending of your story. I do not buy books, because I know the ending and like it. I buy them, because I am interested in the story that they advertise and I am curious about how the story solves the problem that it poses. Solving this problem may take several books in a series, but in the end, I want to know how it is dealt with. In agreement with the puzzle analogy above, this finale of a series should be well prepared and inevitable. If the story is told well and captured my interest throughout an entire series of books, I do not see how it could disappoint me -- unless it does not fit the preceding story.
Bringing all of this together, I would answer your question as follows: I think your question is not whether the ending of your story should cater to the tastes of your audience. The ending of a story is the inevitable result of the story itself -- changing it means to change everything that happened before. Effectively, you will end up a different story.
Rather, your question is whether you should write your stories for your audience or for yourself. And this question, you have to answer for yourself (as other commentators already observed).
(1) Example: Stephen King's story "The Secret Window". The ending of this book feels like an enormous cheat. When I read it, I was under the impression that King was scared to write down the ending that the entire story was pointing to -- because it is ugly and bleak and horrible and hardly anybody wants to read a story like that. However, giving his story an unexpected "happy" ending turned out just as desastrous. The reason is that it was not fitting the preceding 90% of the story. It felt wrong on every level, and I felt betrayed and lied to by Stepehen King. The fact that I immediately remembered the "Secret Window" -- a story that I first saw in its movie adaption twelve years ago and read shortly after -- when I saw your question tells you something about how lasting the bad impression was that I took from the book. If I hadn't known Stephen King to be an occasional storytelling genius when I read "The Secret Window", I would have never touched another Stephen King book in my life.