Fix infinite loop of `waitUntilNotFound'.