code: public static void logout() {
  
          CmsObject cms = A_CmsUI.getCmsObject();
          if (UI.getCurrent() instanceof CmsAppWorkplaceUi) {
              ((CmsAppWorkplaceUi)UI.getCurrent()).onWindowClose();
          }
          String loggedInUser = cms.getRequestContext().getCurrentUser().getName();
          UI.getCurrent().getSession().close();
          String loginLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget(
              cms,
              CmsWorkplaceLoginHandler.LOGIN_HANDLER,
              false);
          VaadinService.getCurrentRequest().getWrappedSession().invalidate();
          Page.getCurrent().setLocation(loginLink);
          // logout was successful
          if (LOG.isInfoEnabled()) {
              LOG.info(
                  org.opencms.jsp.Messages.get().getBundle().key(
                      org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3,
                      loggedInUser,
                      "{workplace logout option}",
                      cms.getRequestContext().getRemoteAddress()));
          }
      }
docs: Logs the current user out by invalidating the session an reloading the current URI.<p>
  Important:  This works only within vaadin apps.<p>