Running simulation until all tasks are done.