Catch "MySQL server has gone away" with MySQLi too and exit properly