Close record file before cleanup