use endTask() when you want to stop. Other people, expand below
Here’s what I might do:
Create an integer variable that is initially set to 0.
At the end of each task (in the task code), add 1 to the aforementioned variable.
Program your other code to not run until the aforementioned variable equals 2.