Don't remove shutdown hook when closing DB
I found the cause of this crash by chance while testing !643 (merged). If the VM exits without calling close() first, the shutdown hook calls close() and tries to remove itself.
There's actually no need to remove the hook in the case of a clean shutdown because we already return from close() if it's been called before. So the fix is just to leave the hook in place.
Needs backport. Closes #1120 (closed).