make sure files are closed before attempting to rename