/**
   * End the session with the remote controllable device
   *
   * @return {@link Status} of endSession execution
   */
  public Status endSession() {
    Log.i(TAG, "endSession has been called, leaving the session");

    if (sessionId == null) {
      Log.w(TAG, "Fail to execute endSession, sessionId is NULL, returning Status of FAIL");
      return Status.FAIL;
    }

    Status status;
    try {
      status = connMgr.leaveSession(sessionId);
    } catch (ControlPanelException cpe) {
      Log.e(
          TAG,
          "Failed to call leaveSession, Error: '"
              + cpe.getMessage()
              + "', returning status of FAIL");
      return Status.FAIL;
    }

    String logMsg = "endSession return Status is: '" + status + "'";

    if (status == Status.OK) {
      sessionId = null;
      Log.i(TAG, logMsg);

      // Unregister the session relevant events
      connMgr.unregisterEventListener(ConnManagerEventType.SESSION_JOINED, this);
      connMgr.unregisterEventListener(ConnManagerEventType.SESSION_LOST, this);
      connMgr.unregisterEventListener(ConnManagerEventType.SESSION_JOIN_FAIL, this);
    } else {
      Log.w(TAG, logMsg);
    }

    return status;
  } // endSession