code: def on_terminate(func):
      
      def exit_function(*args):
          func()
          exit(0)
      signal.signal(signal.SIGTERM, exit_function)
docs: Register a signal handler to execute when Maltego forcibly terminates the transform.