code: def onStopping(self):
          
          # Log stats should happen before any kind of reset or clearing
          if self.config.STACK_COMPANION == 1:
              add_stop_time(self.ledger_dir, self.utc_epoch())
  
          self.logstats()
          self.reset()
  
          # Stop the ledgers
          for ledger in self.ledgers:
              try:
                  ledger.stop()
              except Exception as ex:
                  logger.exception('{} got exception while stopping ledger: {}'.format(self, ex))
  
          self.nodestack.stop()
          self.clientstack.stop()
  
          self.closeAllKVStores()
  
          self._info_tool.stop()
          self.mode = None
          self.execute_hook(NodeHooks.POST_NODE_STOPPED)
docs: Actions to be performed on stopping the node.
  
          - Close the UDP socket of the nodestack