These moments are always very embarrassing to watch.
I witnessed twice recitals of organists with splendid international reputations (performances were during two separate international organ conferences, so it was really big deal). The playing were very poor. The more they played the worse it became. Mistakes every line or so, tempo became slower and slower etc.
These things can happen to any of us - maybe they were ill, maybe their families were in a state of emergency, who knows, or maybe they were just unprepared.
The question is what to do when you are in such a situation yourself?
Obviously, keep playing, don't stop no matter what, don't try to correct your mistakes, keep up the flow of the music and keep your eyes fixed on the current measure. Remember all this is largely mental issue. So if you can control your mind and keep it from panicking (while knowing that you haven't done your homework) - you'll win.
It's very difficult, though, to fool yourself, to make yourself forget that you're unprepared.
But there's no other way, only focusing your mind, like a piece of steal.
The opposite can be also true - the organist can be extremely well prepared but the performance can bomb.
[Thanks to Karl]