docstr: This method is used to terminate all the objects (threads, processes, etc..) created by the app.
docstr_tok: ["This","method","is","used","to","terminate","all","the","objects","(","threads",",","processes",",","etc","..",")","created","by","the","app","."]
code: def terminate(self) -> None:
      """This method is used to terminate all the objects (threads, processes, etc..) created by the app."""
      logger.info(
          "Your Lightning App is being stopped. This won't take long."
      )
      self.done = False
      has_messaged = False
      while not self.done:
          try:
              if self.app.backend is not None:
                  self.app.backend.stop_all_works(self.app.works)
  
              if self.app.api_publish_state_queue:
                  for work in self.app.works:
                      self._add_stopped_status_to_work(work)
  
                  # Publish the updated state and wait for the frontend to update.
                  self.app.api_publish_state_queue.put(
                      (self.app.state, self.app.status)
                  )
  
              for thread in self.threads + self.app.threads:
                  thread.join(timeout=0)
  
              for frontend in self.app.frontends.values():
                  frontend.stop_server()
  
              for proc in list(self.processes.values()) + list(
                  self.app.processes.values()
              ):
                  if proc.is_alive():
                      proc.kill()
  
              self.done = True
  
          except KeyboardInterrupt:
              if not has_messaged:
                  logger.info(
                      "Your Lightning App is being stopped. This won't take long."
                  )
              has_messaged = True
  
          if self.done:
              logger.info(
                  "Your Lightning App has been stopped successfully!"
              )
  
      # Inform the application failed.
      if self.app.stage == AppStage.FAILED:
          sys.exit(1)
  
imports: import multiprocessing
  import os
  import sys
  from dataclasses import dataclass, field
  from pathlib import Path
  from threading import Thread
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
  from lightning.app.core import LightningApp, LightningFlow
  from lightning.app.core.constants import APP_SERVER_HOST, APP_SERVER_PORT
  from lightning.app.runners.backends import Backend, BackendType
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.enum import AppStage, CacheCallsKeys, WorkStageStatus, make_status
  from lightning.app.utilities.load_app import load_app_from_file
  from lightning.app.utilities.proxies import WorkRunner
label_desc: Use image node_id 2 for calling the Runtime obj's underlying member method code with example usage: obj.terminate() without return types