You can execute the statement SHUTDOWN and then close the connection.
The SHUTDOWN command will make H2 free all resources related to the connection immediately. That will, for example, allow you to get rid of an embedded H2 database when you redeploy a web application.