Improvement: added a shutdown hook to close the in-memory database in
case of any shutdown command.