Fix bug in which writeFileHandle was cleared when the record window was closed.