Properly handle disconnections from the MySQL server.