# File lib/amqp/connection.rb, line 60
  def self.stop(reply_code = 200, reply_text = "Goodbye", &block)
    return if @connection.nil? || self.closing?

    EM.next_tick do
      if AMQP.channel and AMQP.channel.open? and AMQP.channel.connection.open?
        AMQP.channel.close
      end
      AMQP.channel = nil


      shim = Proc.new {
        block.call

        AMQP.connection = nil
      }
      @connection.disconnect(reply_code, reply_text, &shim)
    end
  end