I tried to block the "Change Settings" button's action until the code is finished here:
if (!isLooping()) { button.mousePressed(setupSettings); }
But it only works for the first loop. From the second loop onwards, the user is able to press the button as many times as they wish and the loops starts to nest on top of the other ones already running.
I think it has to be with the async function, but I can't figure out a solution to this.