Properly close files when destroying procs