Fix early stop condition

While editing original Uri's messy patch
I have incorrectly simplified the logic
condition. Here is the correct original
version, as it was tested.

bench: 8502826
Merge remote-tracking branch 'upstream/master'