Handle EINTR from close() and minor tidy.