No one commenting on this post about the trick ending ('it was all a dream' 'the protagonist was dead all along' 'it's an artificial reality') mentions the locus classicus, An Occurrence at Owl Creek Bridge, which may be because it's so classic it set the paradigm. Nor are they likely to mention Rainbow (我心飞翔.) What I like about that one is that The Ending *isn't* explained. It's just there, presented as fact, and you get to figure out what it means for the action of the film as a whole.
Here's a taste of Rainbow, with unrecognizable quondem Bo Pi as the greasy school master. And heavens. Is this the whole film, or just a few minutes of it?