code: def disconnect_app(logout: bool = False):
      """Disconnect from an App."""
      _clean_lightning_connection()
  
      connected_file = os.path.join(
          _LIGHTNING_CONNECTION_FOLDER, "connect.txt"
      )
      if os.path.exists(connected_file):
          with open(connected_file) as f:
              result = f.readlines()[0].replace("\n", "")
  
          os.remove(connected_file)
          commands_folder = os.path.join(
              _LIGHTNING_CONNECTION_FOLDER, "commands"
          )
          if os.path.exists(commands_folder):
              shutil.rmtree(commands_folder)
  
          if result == "localhost":
              click.echo(
                  "You are disconnected from the local Lightning App."
              )
          else:
              click.echo(
                  f"You are disconnected from the cloud Lightning App: {result}."
              )
      else:
          if not logout:
              click.echo(
                  "You aren't connected to any Lightning App. "
                  "Please use `lightning connect app_name_or_id` to connect to one."
              )
  
imports: import json
  import os
  import shutil
  import sys
  from subprocess import Popen
  from typing import List, Optional, Tuple
  import click
  import psutil
  from lightning_utilities.core.imports import package_available
  from rich.progress import Progress
  from lightning.app.utilities.cli_helpers import _get_app_display_name, _LightningAppOpenAPIRetriever
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.enum import OpenAPITags
  from lightning.app.utilities.log import get_logfile
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 2 for calling a global function with example usage: disconnect_app(logout) without return types