Improve database release/shutdown procedures to reduce occasional Exceptions such as "IllegalStateException: Illegal access:..."