How to shut-down built-in Flask server?
<p>Whenever I ran my experimental Flask server, it used to say <code>Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)</code>.
It indeed did quit whenever I pressed <kbd>Ctrl</kbd> + <kbd>C</kbd>. But after I ran a threaded Flask server, pressing <kbd>Ctrl</kbd> + <kbd>C</kbd> closes the server but does not exit the process. I must manually(painstakingly), kill the process, do <code>jobs</code> to determine the process number then <code>kill</code> it, wait until it is terminated before I restart the server. What is wrong with it? Do all threaded servers behave this way?</p>

<p><strong>Edit</strong></p>

<p>Do this in your <code>application.py</code>.</p>

<pre><code>from flask-sse import sse

# your code...
app = Flask(__name__)
app.config["REDIS_URL"] = "redis://localhost"
app.register_blueprint(sse, url_prefix='/foo')
# code again
sse.publish() # anything you want

# much code

if __name__ == "__main__":
app.run(threaded=True, host="0.0.0.0")
</code></pre>

<p>Now run the file as <code>python application.py</code>. No need to do <code>flask run...</code>.
Now it says 
<code>Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)</code></p>

<p>Now try to press 
    <kbd>Ctrl</kbd> + <kbd>C</kbd>. Try reloading your webpage, it won't, implying the server closed. But look at the terminal, the process still hasn't terminated. 
If you look at the page <code>/foo</code>, you still seem to be getting events. It doesn't stop. It might imply that this thread hasn't stopped.
Now it is a painful effort to kill the process each time. Is there a solution?</p>