code: func (mtask *managedTask) waitForStopReported() bool {
  	stoppedSentBool := make(chan struct{})
  	taskStopped := false
  	go func() {
  		for i := 0; i < _maxStoppedWaitTimes; i++ {
  			// ensure that we block until apitaskstatus.TaskStopped is actually sent
  			sentStatus := mtask.GetSentStatus()
  			if sentStatus >= apitaskstatus.TaskStopped {
  				taskStopped = true
  				break
  			}
  			seelog.Warnf("Managed task [%s]: blocking cleanup until the task has been reported stopped. SentStatus: %s (%d/%d)",
  				mtask.Arn, sentStatus.String(), i+1, _maxStoppedWaitTimes)
  			mtask._time.Sleep(_stoppedSentWaitInterval)
  		}
  		stoppedSentBool <- struct{}{}
  		close(stoppedSentBool)
  	}()
  	// wait for apitaskstatus.TaskStopped to be sent
  	for !mtask.waitEvent(stoppedSentBool) {
  	}
  	return taskStopped
  }
docs: // waitForStopReported will wait for the task to be reported stopped and return true, or will time-out and return false.
  // Messages on the mtask.dockerMessages and mtask.acsMessages channels will be handled while this function is waiting.