Closes files if early termination