More robust file descriptor closing prevention.