Add common code for handling close(2) failures