PsychoPy ends experiment when loop is terminated

PsychoPy version (e.g. 1.84.x):2020.2.4

In my experiment, I inserted a code component to count the number of specific responses based on a rating scale.
Here is what I have done:
Code component:
Begin Experiment:
myCount = 0

End Routine:
if rating.getRating() == 5:
myCount = myCount + 1

if myCount == 3:
trials.finished = TRUE

PsychoPy terminates the loop when I click “5” three times on the rating scale and closes the experiment (despite there is another routine). How can I tell PsychoPy to switch to the next routine and not to quit the whole experiment?

Thank you very much!

Is trials the name of the loop surrounding your routine, or of a larger loop surrounding the whole thing?

Hi TParsons!
trials is the name of the loop surrounding one routine.


if myCount == 3:

Including break (instead of trials.finished = TRUE) solved my problem.