exit - Exit the process


use Tk qw(exit);


Terminate the process, returning returnCode (an integer) to the system as the exit status. If returnCode isn't specified then it defaults to 0. This command replaces the perl command by the same name. It is identical to perl's exit command except that before exiting it destroys all the windows managed by the process. This allows various cleanup operations to be performed, such as removing application names from the global registry of applications.


This function is necessary as calling perl's exit from inside a callback associated with a binding (including Menu and Button -command callbacks) can result in memory access violations due to leaving Tk's internal data-structures in an inconsistent state.

Workround is to either $mainwindow->destroy or use Tk::exit as described here.


exit, process