The method
Kernel#exit
terminates your program, returning a
status value to the operating system. However, unlike some languages,
exit
doesn't just terminate the program immediately.
Kernel#exit
first raises a
SystemExit
exception, which you may catch, and then performs a
number of cleanup actions, including running any registered
at_exit
methods and object finalizers. See the reference for
Kernel#exit
beginning on page 415 for details.