code: func (c *client) shutdownContainer(ctr *container) error {
  	var err error
  	const waitTimeout = time.Minute * 5
  
  	if !ctr.terminateInvoked {
  		err = ctr.hcsContainer.Shutdown()
  	}
  
  	if hcsshim.IsPending(err) || ctr.terminateInvoked {
  		err = ctr.hcsContainer.WaitTimeout(waitTimeout)
  	} else if hcsshim.IsAlreadyStopped(err) {
  		err = nil
  	}
  
  	if err != nil {
  		c.logger.WithError(err).WithField("container", ctr.id).
  			Debug("failed to shutdown container, terminating it")
  		terminateErr := c.terminateContainer(ctr)
  		if terminateErr != nil {
  			c.logger.WithError(terminateErr).WithField("container", ctr.id).
  				Error("failed to shutdown container, and subsequent terminate also failed")
  			return fmt.Errorf("%s: subsequent terminate failed %s", err, terminateErr)
  		}
  		return err
  	}
  
  	return nil
  }
docs: // ctr mutex must be held when calling this function.