code: public static function end()
      {
          if (!empty(self::$stack)) {
              $widget = array_pop(self::$stack);
              if (get_class($widget) === get_called_class()) {
                  /* @var $widget Widget */
                  if ($widget->beforeRun()) {
                      $result = $widget->run();
                      $result = $widget->afterRun($result);
                      echo $result;
                  }
  
                  return $widget;
              }
  
              throw new InvalidCallException('Expecting end() of ' . get_class($widget) . ', found ' . get_called_class());
          }
  
          throw new InvalidCallException('Unexpected ' . get_called_class() . '::end() call. A matching begin() is not found.');
      }
docs: Ends a widget.
  Note that the rendering result of the widget is directly echoed out.
  @return static the widget instance that is ended.
  @throws InvalidCallException if [[begin()]] and [[end()]] calls are not properly nested
  @see begin()