exit is just that, it is designed to exit the program. What you need to look for is a subroutine to destroy the window. You don't mention what you are using for a GUI, but assuming it's Tk, something like command => $widget->destroy(); should work.
Update of course, if you would like this to actually work you should probably use command => sub{ $widget->destroy() } as tye most kindly points out below. (Sorry, it's been many months since I last looked at Tk)