Don't exit, instead do
$mw->destroy [download]
In reply to Re: Code after MainLoop; Tk by Anonymous Monk in thread Code after MainLoop; Tk by PerlCowboy