diff --git a/collects/mred/exit.ss b/collects/mred/exit.ss index c6ba2f53..e7cc5684 100644 --- a/collects/mred/exit.ss +++ b/collects/mred/exit.ss @@ -33,23 +33,28 @@ [else (loop (cdr cb-list))]))))) (define -exit - (lambda () - (let/ec k - (when (and (mred:preferences:get-preference 'mred:verify-exit) - (not (let ([w (if (eq? wx:platform 'macintosh) - "quit" - "exit")] - [capW (if (eq? wx:platform 'macintosh) - "Quit" - "Exit")]) - (mred:gui-utils:get-choice - (string-append "Are you sure you want to " w "?") - capW "Cancel")))) - (k #f)) - (run-exit-callbacks) - (if (null? exit-callbacks) - (begin (when mred:debug:exit? - (exit)) - #t) - #f)))))) + (let ([exiting? #f]) + (lambda () + (unless exiting? + (dynamic-wind + (lambda () (set! exiting? #t)) + (lambda () + (let/ec k + (when (and (mred:preferences:get-preference 'mred:verify-exit) + (not (let ([w (if (eq? wx:platform 'macintosh) + "quit" + "exit")] + [capW (if (eq? wx:platform 'macintosh) + "Quit" + "Exit")]) + (mred:gui-utils:get-choice + (string-append "Are you sure you want to " w "?") + capW "Cancel")))) + (k #f)) + (run-exit-callbacks) + (if (null? exit-callbacks) + (exit) + #f))) + (lambda () (set! exiting? #f))))))))) +