Actions are atomic. Which means that no other action, even in an asynchronous macro, can execute while an action is running. (The obvious exception are actions which contain other actions.) There is a way to make groups of sequential actions atomic, and that's by using semaphores around each place that you need to be atomic.
In this case one of the two actions you are testing for is an internal KM variable. The other condition you are testing for is an external condition (an image find) which can occur completely independently of the KM Engine.
One way you can guarantee which action occurs first is to ensure that each time you assign a value to the variable, (in any macro) protect that assignment with a semaphore.
If the two conditions you were testing for were both outside of KM, then you could never know which one occurs first (even if KM let you know which condition occurred first) because even KM wouldn't really know. However in this case one of the two conditions is a KM variable which is within your control thus a 100% solution is possible using semaphores.