code: func (c *client) terminateContainer(ctr *container) error {
  	const terminateTimeout = time.Minute * 5
  	ctr.terminateInvoked = true
  	err := ctr.hcsContainer.Terminate()
  
  	if hcsshim.IsPending(err) {
  		err = ctr.hcsContainer.WaitTimeout(terminateTimeout)
  	} else if hcsshim.IsAlreadyStopped(err) {
  		err = nil
  	}
  
  	if err != nil {
  		c.logger.WithError(err).WithField("container", ctr.id).
  			Debug("failed to terminate container")
  		return err
  	}
  
  	return nil
  }
docs: // ctr mutex must be held when calling this function.