title: Thread still runs when flask server exits
body: <p>As titles describe, I create a separate thread to do a long task in <code>Flask</code>.</p>
  
  <pre><code>import schedule
  import time
  
  start_time = time.time()
  
  
  def job():
      print("I'm working..." + str(time.time() - start_time))
  
  
  def run_schedule():
      while True:
          schedule.run_pending()
          time.sleep(1)
  </code></pre>
  
  <p>When I press <code>Ctrl + c</code> to terminate the server, the thread still <code>prints</code>. <strong>How can I stop the thread when server exits?</strong></p>