> my $window => Gtk2::Window -> new; > $window -> signal_connect ( 'delete_event', sub { Gtk2 -> main_quit; } ); Connect this to 'destroy' instead of 'delete-event'. The handler for 'delete-event' is supposed to return a boolean value saying "i handled this" or "i didn't handle this", that is typically used to inhibit destruction of the window. You're not doing that, though. The default action from 'delete-event' is to destroy the window, which will cause the 'destroy' event to fire. Of course, you can also get 'destroy' from other places in your program. So, if you connect the quit of the main loop to the main window's 'destroy' rather than 'delete-event', you get a more robust program. #### #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; my $window = Gtk2::Window->new; $window->add( Gtk2::Label->new("I'm a banana!") ); $window->show_all; $window->signal_connect( delete_event => sub { return !ask( $_[0], "Really quit?" ); } ); $window->signal_connect( destroy => sub { Gtk2->main_quit } ); Gtk2->main; sub ask { my ( $parent, $question ) = @_; my $msgbox = Gtk2::MessageDialog->new( $parent, [], 'question', 'yes-no', $question ); my $response = $msgbox->run(); $msgbox->destroy; return $response eq 'yes'; }