When the JVM exists normally, H2 normally closes the database itself, if you haven't done it yourself explicitly.
In worst case scenarios, you might be able to use Thread#setDefaultUncaughtExceptionHandler
to terminate the JVM safely and/or close the database