It's when you suddenly (or something makes you) change your mind just at the right moment to not make a mistake that you would regret about for the rest of your life.
Example: Apparently, the magic of love seemed to have clouded his mind, and by all signs, it looked like his bachelor life was about to be over and the marriage seemed inevitable, but at the last moment he [???], gathered what remained of his will into a fist, and fled to Moscow.