use strict; use Tk; my $mw = new MainWindow(); ... $mw->bind("",sub { $mw->destroy }); MainLoop;