Fix test on Windows

Close file before deleting