close after write error