Close file handle before attempting removal

Fixes earlier commit; forgot that opening a file defaults to a lock under Windows