Avoid deadlock on host thread termination