Closing file handles to fix test failures on windows