sub buildGui { $goMainWindow = new MainWindow; #pack your Exit button first in the list my ($oExit) = $goMainWindow->Button(-text => 'Exit', -command => sub{exit}, )->pack( -padx => '5', -pady => '5', -side => 'bottom', ); ...... ....... .....