An Occurence at Owl Creek Bridge
(1962)

The Confederate fugitive makes it back to his home, where he sees his wife. Just as he is about to embrace her, he starts choking, his home disappears, and we see that the fugitive is back at the gallows, being hanged.

The rope never really broke, and he never really escaped- that was all part of an elaborate fantasy he conjured up in the few seconds he had before dying.

Thanks John L!