Fix #13604 - STW handshake/thread shutdown race condition.