code: def experiment_exit_handler():
      """
      Method for handling the experiment when any unusual program ending occurs.
      The `atexit` handler should be put in the last, since, as long as the program ends, it will be called.
      Thus, if any exception or user interruption occurs beforehand, we should handle them first. Once `R` is
      ended, another call of `R.end_exp` will not take effect.
  
      Limitations:
      - If pdb is used in your program, excepthook will not be triggered when it ends.  The status will be finished
      """
      sys.excepthook = (
          experiment_exception_hook  # handle uncaught exception
      )
      atexit.register(R.end_exp, recorder_status=Recorder.STATUS_FI)
  
file_path: qlib/qlib/workflow/utils.py
imports: import atexit
  import logging
  import sys
  import traceback
  from ..log import get_module_logger
  from .None import R
  from .recorder import Recorder
label_desc: Use image node_id 1 for calling a global function with example usage: experiment_exit_handler() without return types