def process(errback = nil, audit = nil, &block)
      # yield if not shutting down (continuing) or if already requested shutdown.
      if continue? || @shutdown_scheduled
        block.call if block
        return true
      end

      # ensure we have an audit, creating a temporary audit if necessary.
      sender = Sender.instance
      agent_identity = sender.identity
      if audit
        case @level
        when REBOOT, STOP, TERMINATE
          operation = "/forwarder/shutdown"
          payload = {:agent_identity => agent_identity, :kind => @level}
        else
          raise InvalidLevel.new("Unexpected shutdown level: #{@level.inspect}")
        end

        # request shutdown (kind indicated by operation and/or payload).
        audit.append_info("Shutdown requested: #{self}")
        sender.send_request(operation, payload) do |r|
          res = OperationResult.from_results(r)
          if res.success?
            @shutdown_scheduled = true
            block.call if block
          else
            fail(errback, audit, "Failed to shutdown instance", res)
          end
        end
      else
        AuditProxy.create(agent_identity, "Shutdown requested: #{self}") do |new_audit|
          process(errback, new_audit, &block)
        end
      end
      true
    rescue Exception => e
      fail(errback, audit, e)
    end
def process(errback = nil, audit = nil, &block)
      # yield if not shutting down (continuing) or if already requested shutdown.
      if continue? || @shutdown_scheduled
        block.call if block
        return true
      end

      # ensure we have an audit, creating a temporary audit if necessary.
      sender = Sender.instance
      agent_identity = sender.identity
      if audit
        case @level
        when REBOOT, STOP, TERMINATE
          operation = "/forwarder/shutdown"
          payload = {:agent_identity => agent_identity, :kind => @level}
        else
          raise InvalidLevel.new("Unexpected shutdown level: #{@level.inspect}")
        end

        # request shutdown (kind indicated by operation and/or payload).
        audit.append_info("Shutdown requested: #{self}")
        sender.send_request(operation, payload) do |r|
          res = OperationResult.from_results(r)
          if res.success?
            @shutdown_scheduled = true
            block.call if block
          else
            fail(errback, audit, "Failed to shutdown instance", res)
          end
        end
      else
        AuditProxy.create(agent_identity, "Shutdown requested: #{self}") do |new_audit|
          process(errback, new_audit, &block)
        end
      end
      true
    rescue Exception => e
      fail(errback, audit, e)
    end
Processes shutdown requests by communicating the need to shutdown an
 instance with the core agent, if necessary.

 === Parameters
 errback(Proc):: error handler or nil
 audit(Audit):: audit for shutdown action, if needed, or nil.

 === Block
 block(Proc):: continuation block for successful handling of shutdown or nil

 === Return
 always true