Close database connection on shutdown