Fix close file bug after closing an open file