How to check if streamlit stopped

I have a bit of code in a while loop that I want to break from if someone hits the stop button.

The while loop can be long and if you hit stop it stops the output display to streamlit but the while loop is actually still running. Is there a way to check if that stop button has been pressed to break the while loop? I tried to use a st.button() but I cant because the function that has the while loop is running concurrent futures and I don’t want to generate a ton of stop buttons :slight_smile:

Below is picture of the stop button that pops up on top right of window during run times.