The JVM exits when System.exit method is invoked or when the last non daemon
thread exits. When the virtual machine begins its shutdown sequence it starts
the execution of registered shutdown hooks in some unspecified order. The shutdown
hooks are useful to perform clean up activities.