Have a look at the following code
The finally block will never get executed if you think that it will always get executed.
The System.exit method halts the execution of the current thread and all others dead in their tracks. The presence of a finally clause does not give a thread special permission to continue executing.
For any clean up before JVM exits, you must use ShutdownHook.