Fix closing file before unlink into regression tests.