docs: def on_ready_to_stop(self):
          """Invoked when the consumer is ready to stop."""
  
          # Set the state to shutting down if it wasn't set as that during loop
          self.set_state(self.STATE_SHUTTING_DOWN)
  
          # Reset any signal handlers
          signal.signal(signal.SIGABRT, signal.SIG_IGN)
          signal.signal(signal.SIGINT, signal.SIG_IGN)
          signal.signal(signal.SIGPROF, signal.SIG_IGN)
          signal.signal(signal.SIGTERM, signal.SIG_IGN)
  
          # Allow the consumer to gracefully stop and then stop the IOLoop
          if self.consumer:
              self.stop_consumer()
  
          # Clear IOLoop constructs
          self.consumer_lock = None
  
          # Stop the IOLoop
          if self.ioloop:
              LOGGER.debug('Stopping IOLoop')
              self.ioloop.stop()
  
          # Note that shutdown is complete and set the state accordingly
          self.set_state(self.STATE_STOPPED)
          LOGGER.info('Shutdown complete')