Close the file descriptor in the same method that had been opened.

MD-20923