Fixing bug in Windows file closing code