Called when daemon is stopped. Basically just AMQP's ``.close()``
        functions to ensure clean exit.

        You can override this, but don't forget to call it thru ``super()``, or
        the AMQP communication won't be closed properly!

def onExit(self):
        """
        Called when daemon is stopped. Basically just AMQP's ``.close()``
        functions to ensure clean exit.

        You can override this, but don't forget to call it thru ``super()``, or
        the AMQP communication won't be closed properly!
        """
        def try_call(fn):
            try:
                fn()
            except (pika.exceptions.ChannelClosed, AttributeError,
                    pika.exceptions.ConnectionClosed):
                return

        if hasattr(self, "channel"):
            try_call(self.channel.cancel)
            try_call(self.channel.close)
            try_call(self.connection.close)