fix a devious bug always close a file before any interrupt