Closing file handles to fix test failures on windows
Merge pull request #331 from hbeeken/issue-326

Proposed fix for Issue #326