properly close file in operstate