Endings can be hard to pull off satisfactorily, in all kinds of fiction. The famous "twist" is a popular device in short stories especially, but whatever the ending, it must satisfy the reader. It doesn't have to be happy (ah...poor Anna Karenina), but it must complete the novel or story. And as short story writers are constantly reminded, the reader must be given enough information for him/her not to feel cheated, while maintaining the surprise.
I have just finished a novel where the entire book turns out to be fantasy. The final part begins with the statement that "none of this really happened", and I felt really furious. How dare the author pull a stunt like that? It's like the famous dream twist ("I woke up, and it had all been a dream"). You just can't get away with it.
The author of this novel is very well-known, and has written at least one masterpiece (which I found utterly compelling), so I won't name him/her and spoil this book for anyone yet to read it. But when I finished it, I was so mad I would have hurled it across the room, if it hadn't been on my Kindle (another disadvantage of Kindles!).