title: Stop Locust When Specified Number Of User Tasks Complete
body: <p>In my scenario, I'm running Locust without the web UI. The command I'm using is</p>
  
  <pre><code>locust -f my_locust_file --no_web -c 20 -r 4     # as a hack I add -t 10s
  </code></pre>
  
  <p>This corresponds to a 4 users being hatched every second up to a total of 20 users.</p>
  
  <p>My objective is to have each of the 20 locust users execute a task and I'd like the locust run to complete and exit when the last user's (20th user) task completes.  The collected statistics should only include the response times associated with each task.</p>
  
  <p>In this scenario, 5 tasks (user scenarios) have been identified which can be randomly associated with a user:</p>
  
  <pre><code>class UserScenarios(TaskSet):
      tasks = [Sequence_One, ServerSequence, Components_Sequence, Embedded_Sequence, Connectivity_Sequence]
  
  class MyLocust(HttpLocust):
      def __init__(self):
          super().__init__()
          MyLocust.counter += 1
          print(f"Counter = {MyLocust.counter}")
  
      counter = 0
      task_set = UserScenarios
      wait_time = between(1, 1)
      host = 'https://*****.com'
  </code></pre>
  
  <p>Each task (user scenario) corresponds to a different sequence of 3 or 4 pages that should be loaded in order. An example sanitized and simplified sequence consisting of 2 pages is:</p>
  
  <pre><code>class Sequence_One(TaskSequence):
  
      @seq_task(1)
      def get_task1(self):
          response = self.client.get(url='https://****',
                                     name='https://****',
                                     timeout=30,
                                     allow_redirects=False,
                                     headers={...})   
  
      @seq_task(2)
      def get_task2(self):
          response = self.client.get(url='https://****',
                                     name='https://****',
                                     timeout=30,
                                     allow_redirects=False,
                                     headers={...})  
  </code></pre>
  
  <p>Is there a way to stop the test after the 20th (nth) user task completes?  If every task visits 4 pages for example, I want the test to terminate after the 20*4 = 80 page request is made.  In fact only 80 total page requests should be made as part of this test.</p>
  
  <p>My experience with this test is that page requests continue to be made after the last user task completes until I either manually stop the test or use a time limit which is a bit longer than the tasks actually need to complete.</p>