Close file descriptors before unlinking

Unlinking a file before closing may not be supported on non-POSIX systems
such as Windows. This allows more tests to run to completion.
Merge pull request #75 from ispedals/winTestFixes

Close file descriptors before unlinking