code: func (r *runtimeVM) StopContainer(ctx context.Context, c *Container, timeout int64) error {
  	logrus.Debug("runtimeVM.StopContainer() start")
  	defer logrus.Debug("runtimeVM.StopContainer() end")
  
  	// Lock the container
  	c.opLock.Lock()
  	defer c.opLock.Unlock()
  
  	// Cancel the context before returning to ensure goroutines are stopped.
  	ctx, cancel := context.WithCancel(r.ctx)
  	defer cancel()
  
  	stopCh := make(chan error)
  	go func() {
  		if _, _, err := r.wait(ctx, c.ID(), ""); err != nil {
  			stopCh <- errdefs.FromGRPC(err)
  		}
  
  		close(stopCh)
  	}()
  
  	var sig syscall.Signal
  
  	if timeout > 0 {
  		sig = c.StopSignal()
  		// Send a stopping signal to the container
  		if err := r.kill(ctx, c.ID(), "", sig, false); err != nil {
  			return err
  		}
  
  		timeoutDuration := time.Duration(timeout) * time.Second
  
  		err := r.waitCtrTerminate(sig, stopCh, timeoutDuration)
  		if err == nil {
  			return nil
  		}
  		logrus.Warnf("%v", err)
  	}
  
  	sig = syscall.SIGKILL
  	// Send a SIGKILL signal to the container
  	if err := r.kill(ctx, c.ID(), "", sig, false); err != nil {
  		return err
  	}
  
  	if err := r.waitCtrTerminate(sig, stopCh, killContainerTimeout); err != nil {
  		logrus.Errorf("%v", err)
  		return err
  	}
  
  	return nil
  }
docs: // StopContainer stops a container. Timeout is given in seconds.