code: func (c *client) reapContainer(ctr *container, p *process, exitCode int, exitedAt time.Time, eventErr error, logger *logrus.Entry) (int, error) {
  	// Update container status
  	ctr.Lock()
  	ctr.status = containerd.Stopped
  	ctr.exitedAt = exitedAt
  	ctr.exitCode = uint32(exitCode)
  	close(ctr.waitCh)
  
  	if err := c.shutdownContainer(ctr); err != nil {
  		exitCode = -1
  		logger.WithError(err).Warn("failed to shutdown container")
  		thisErr := errors.Wrap(err, "failed to shutdown container")
  		if eventErr != nil {
  			eventErr = errors.Wrap(eventErr, thisErr.Error())
  		} else {
  			eventErr = thisErr
  		}
  	} else {
  		logger.Debug("completed container shutdown")
  	}
  	ctr.Unlock()
  
  	if err := ctr.hcsContainer.Close(); err != nil {
  		exitCode = -1
  		logger.WithError(err).Error("failed to clean hcs container resources")
  		thisErr := errors.Wrap(err, "failed to terminate container")
  		if eventErr != nil {
  			eventErr = errors.Wrap(eventErr, thisErr.Error())
  		} else {
  			eventErr = thisErr
  		}
  	}
  	return exitCode, eventErr
  }
docs: // reapContainer shuts down the container and releases associated resources. It returns
  // the error to be logged in the eventInfo sent back to the monitor.