TST: do not remove files while they are open

Fixes WindowsError: [Error 32] The process cannot access the file because it is being used by another process