code: def exit(self, result=0, msg=None, *args, **kwargs):
      
      if self._finalizer:
        try:
          self._finalizer()
        except Exception as e:
          try:
            NailgunProtocol.send_stderr(
              self._socket,
              '\nUnexpected exception in finalizer: {!r}\n'.format(e)
            )
          except Exception:
            pass
  
      try:
        # Write a final message to stderr if present.
        if msg:
          NailgunProtocol.send_stderr(self._socket, msg)
  
        # Send an Exit chunk with the result.
        NailgunProtocol.send_exit_with_code(self._socket, result)
  
        # Shutdown the connected socket.
        teardown_socket(self._socket)
      finally:
        super(DaemonExiter, self).exit(result=result, *args, **kwargs)
docs: Exit the runtime.