Shutting down on database connection loss