code: def is_at_exit():
      
      if _threading_main_thread is not None:
          if not hasattr(threading, "main_thread"):
              return True
          if threading.main_thread() != _threading_main_thread:
              return True
          if not _threading_main_thread.is_alive():
              return True
      return False
docs: Some heuristics to figure out whether this is called at a stage where the Python interpreter is shutting down.
  
      :return: whether the Python interpreter is currently in the process of shutting down
      :rtype: bool