Added handlers for SIGINT and SIGTERM. Saving DB before shutting down.