Auto close file