code: def stop(self):
          
          pid = None
          if os.path.exists(self.pidfile):
              with open(self.pidfile, 'r') as fp:
                  pid = int(fp.read().strip())
  
          if not pid:
              msg = 'pidfile (%s) does not exist. Daemon not running?\n'
              sys.stderr.write(msg % self.pidfile)
              return
  
          try:
              while 1:
                  os.kill(pid, SIGTERM)
                  time.sleep(0.1)
          except OSError as e:
              e = str(e)
              if e.find('No such process') > 0:
                  if os.path.exists(self.pidfile):
                      os.remove(self.pidfile)
                  else:
                      print(e)
                      sys.exit(1)
docs: Stop the daemon.