To stop your loop you can use break with label. It will stop your loop for sure. Code is written in Java but aproach is the same for the all languages.
public void exitFromTheLoop() {
boolean value = true;
loop_label:for (int i = 0; i < 10; i++) {
if(!value) {
System.out.println("iteration: " + i);
break loop_label;
}
}
}
}