close file before renaming

Renaming an open file is not possible on windows