add shutdown hook to close db when shuting down web services.