title: force quit python during thread
body: <p>I'm trying to create a program that spams your screen with terminal windows using threading and would like to create a failsafe button that force quits python when a certain parameter is met. I've tried &quot;os._exit()&quot; and that does not work. I am looking for a way to destroy all threads and force quit python as if my program runs for too long it will crash my computer.</p>
  <pre><code>def spam():
      for i in range(30):
          if i % 10 == 0: # if i is divisible by 10, it pauses for comedic timing 
              time.sleep(2)     
          os.system('open -a Terminal .') # opens terminal window
          playsound('/Users/omar/Downloads/boom.wav') # plays comical 'vine' funny meme audio 
          thread = multiprocessing.Process(target=spam) # creates a thread 
          thread.start()
          if pyautogui.failSafeCheck() == True or pynput.keyboard.Controller().type == 'Keyboard':
              os._exit() and thread.terminate()
          
  spam() # function call
  
  </code></pre>