... $button = $MW->Button( -text => "Shutdown and close", -command => [ \&do_close ] )->pack( -side => 'bottom' ); ... sub abort_routine { debug("+abort_routine"); debug("abort_routine Array_Index: $Array_Index"); # DO SOMETHING USEFUL HERE TO CLEAN UP THE PROCESS debug("-abort_routine"); } sub do_close { $MW->destroy(); }