I’m wondering what version of PsychoPy you are using, because I had similar issues when updating to PsychoPy 2020 from PsychoPy 3.something.something.
See this thread for more info: Loop.finished=true No longer working - #2 by Bobby_Thomas
But in summary I think you might need to change the code for how loops are ended since this was updated.
From that thread:
there a slight change to how you end loops in the latest version of PsychoPy/JS. To end a loop, use the following. In this example, we end the loop on the 2nd repetition of that current loop:
if (currentLoop.thisRepN == 2)
{
trials.finished = true; // to end any loop, use 'trials'
}