So I just noticed that the UiPath.Core.Activities.StopJob does not stop “right away” there is 1-2 seconds(could maybe be more?) where there is time for other “flows” to execute.
I’m not sure if this is a bug or if this is the expected behaviour.
I have solved this by putting a delay after the Stop job activity so no other flows starts to execute.
I believe this is indeed a rather old, but expected behaviour. The workaround is the correct one.
Having said so, I will check with the team to see if this can be improved. I assume what is happening is that the activity makes an API call to Orchestrator, but then gets marked as Completed and the workflow moves forward. As such, when you have other activities after the Stop Job, those would be executed in the small timeframe before the Orchestrator sends its own signal to the robot to actually Stop the job.
If it’s another job that you want to stop, there is also Activities - Should Stop, which you can use to check if you want to continue processing before you pick up a new item or something