code: def stop(self, sig=signal.SIGTERM):
          
  
          if self.pid is None:
              self.pid = self.read_pid()
          if self.pid is None:
              sp = BackgroundProcess.objects.filter(pk=1).first()
              if sp:
                  self.pid = sp.pid
          if self.pid is None or self.pid == 0:
              logger.error("can't determine process id exiting.")
              return False
          if self.pid != getpid():
              # calling from outside the daemon instance
              logger.debug('send sigterm to daemon')
              try:
                  kill(self.pid, sig)
                  return True
              except OSError as e:
                  if e.errno == errno.ESRCH:
                      return False
                  else:
                      return False
  
          logger.debug('start termination of the daemon')
          BackgroundProcess.objects.filter(pk=self.process_id).update(
              last_update=now(),
              message='stopping..')
  
          timeout = time() + 60  # wait max 60 seconds
          self.kill_processes(signal.SIGTERM)
          while self.PROCESSES and time() < timeout:
              self.kill_processes(signal.SIGTERM)
              sleep(1)
          self.kill_processes(signal.SIGKILL)
          BackgroundProcess.objects.filter(pk=self.process_id).update(
              last_update=now(),
              message='stopped')
          logger.debug('termination of the daemon done')
          return True
docs: stop the scheduler and stop all processes