$popup->protocol( 'WM_DELETE_WINDOW', sub { delete($Connections{$username}); $popup->destroy(); } );