code: def _stop_all_nodes(self, wait=False):
          
          failed = 0
          for node in self.get_all_nodes():
              if not node.instance_id:
                  log.warning(
                      "Node `%s` has no instance ID."
                      " Assuming it did not start correctly,"
                      " so removing it anyway from the cluster.", node.name)
                  self.nodes[node.kind].remove(node)
                  continue
              # try and stop node
              try:
                  # wait and pause for and recheck.
                  node.stop(wait)
  
                  self.nodes[node.kind].remove(node)
                  log.debug(
                      "Removed node `%s` from cluster `%s`", node.name, self.name)
              except InstanceNotFoundError as err:
                  log.info(
                      "Node `%s` (instance ID `%s`) was not found;"
                      " assuming it has already been terminated.",
                      node.name, node.instance_id)
              except Exception as err:
                  failed += 1
                  log.error(
                      "Could not stop node `%s` (instance ID `%s`): %s %s",
                      node.name, node.instance_id, err, err.__class__)
          return failed
docs: Terminate all cluster nodes. Return number of failures.