title: Process Still running in background after python script converted to exe with pytoexeconverter
body: <p>Is there a way properly kill a process once the application exits? If yes how can I integrate this in my python script so that it does the job automatically if it exits? I got this code to restart my app when it craches but since the process is still running in the backgroung it doesn't work. Cheers</p>
  
  <pre class="lang-py prettyprint-override"><code>proccess = 'app'
  def checkIfProcessRunning(process):
      '''
      Check if there is any running process that contains the given name processName.
      '''
      #Iterate over the all the running process
      for proc in psutil.process_iter():
          try:
              # Check if process name contains the given name string.
              if process.lower() in proc.name().lower():
                  return True
          except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
              pass
      return False
  
  def ex():
      os.system('TASKKILL /F /IM Trailling.exe')
  
  #atexit.register(ex)
  
  def start_process():
      return os.system(cmd)
  try:
      start_process()
      atexit.register(ex)
      while True:
  
          if checkIfProcessRunning('process'):
              print("Process is running")
              time.sleep(5)
  
          else:
              print("Process is not running")
              start_process()
  
  except Exception as e:
      print(e)
  </code></pre>