tweaked catch_quit