use Tk; $top = new MainWindow; # $top->OnDestroy(sub { $x = 1 }); $top->waitVariable(\$x); MainLoop; warn "Fertig";