After closing the MySQL fd, set it to -1 to prevent a race condition

This updates a2bcfd6 / #213 / #463.

The MySQL library also calls close() on the fd, so it is possible for another
thread to have a new use for the same fd value. By setting the fd to -1, the
second close() will return EBADF without the risk of closing the wrong file.