code: public void disconnect() {
          if (disconnected.compareAndSet(false, true)) {
              log.debug("Disconnect - id: {}", id);
              if (connections != null && !connections.isEmpty()) {
                  log.debug("Closing {} scope connections", connections.size());
                  // close all connections held to Red5 by client
                  for (IConnection con : getConnections()) {
                      try {
                          con.close();
                      } catch (Exception e) {
                          // closing a connection calls into application code, so exception possible
                          log.error("Unexpected exception closing connection {}", e);
                      }
                  }
              } else {
                  log.debug("Connection map is empty or null");
              }
              // unregister client
              removeInstance();
          }
      }
docs: Disconnects client from Red5 application