close file before renaming

Renaming an open file is not possible on windows
Merge pull request #225 from gabriel-samfira/close-file

close file before renaming

Renaming an open file is not possible on windows