code: def daemons_stop(self, timeout=30, kill_children=False):
          def on_terminate(proc):
              logger.debug("process %s terminated with exit code %s", proc.pid, proc.returncode)
          result = True
          if self.my_daemons:
              logger.info("Alignak self-launched daemons stop:")
              start = time.time()
              for daemon in list(self.my_daemons.values()):
                  procs = []
                  if kill_children:
                      procs = daemon['process'].children()
                  procs.append(daemon['process'])
                  for process in procs:
                      try:
                          logger.info("- terminating process %s", process.name())
                          process.terminate()
                      except psutil.AccessDenied:
                          logger.warning("Process %s is %s", process.name(), process.status())
              procs = []
              for daemon in list(self.my_daemons.values()):
                  if kill_children:
                      procs = daemon['process'].children()
                  procs.append(daemon['process'])
              _, alive = psutil.wait_procs(procs, timeout=timeout, callback=on_terminate)
              if alive:
                  for process in alive:
                      logger.warning("Process %s did not stopped, trying to kill", process.name())
                      process.kill()
                  _, alive = psutil.wait_procs(alive, timeout=timeout, callback=on_terminate)
                  if alive:
                      for process in alive:
                          logger.warning("process %s survived SIGKILL; giving up", process.name())
                          result = False
              logger.debug("Stopping daemons duration: %.2f seconds", time.time() - start)
          return result