Adding database cleanup code (db.close()) on SIGINT, SIGTERM.