Can't stop streamlit app using Ctrl+C if the app has been closed in the browser


This is a continuation of a thread from last year: Streamlit server 1.5.1 from command line, hard to stop with CTRL C

This issue does not seem to be resolved and I am perplexed if this is intended behavior or an issue that has not been fixed. Basically if you have a streamlit app running and close the browser, trying to stop the app with ctrl+c does not work.

Steps to reproduce

  • close browser app when streamlit is running
  • ctrl+c in the terminal
  • app does not stop running
  • open the app from the URL link so it opens in the browser again
  • ctrl+c in the terminal
  • app stops running (yay!)

Expected behavior:

  • Launch streamlit from the terminal
  • Close browser
  • ctrl+c in the terminal
  • app stops running (yay!)

Actual behavior:

  • Launch streamlit from the terminal
  • Close browser
  • ctrl+c in the terminal
  • app does not stop running (boo!)

Debug info

  • Streamlit version: 1.19.0
  • Python version: 3.9.12
  • Using venv
  • OS version: Microsoft Windows 11 Home 10.0.22621 Build 22621
  • Browser version: Chrome Version 110.0.5481.178 (Official Build) (64-bit)

Requirements file


1 Like

I can confirm this behavior. When I close the browser tab, the terminal no longer responds to Ctrl+C, I have to kill the process or close the terminal session.
However, if I remember correctly, this behavior only occurs under Windows.
These are my boundary conditions: Windows 10, Firefox, cmder terminal, Streamlit 1.19.0
I have not tried other browsers or other terminals.

I have seen this in Windows 10 with both streamlit and jupyterlab (both use tornado).

I can also confirm. windows 11. finally I had multiple situations the app closing immediately starts if you CTR+click again on the localhost link to start the app again after closing the browser. So at least there is a workaround vs waiting atm.

Same behaviour here on Windows 10 using Microsoft Edge and Windows command line in PyCharm. Indeed, the workaround is to reopen the link to the Streamlit app and the terminal will be able to kill the process successfully.

Normally I just crazy press Ctrl+C till it stops…
Takes around 5 - 20 times :face_exhaling:

I can also confirm this under Windows 10. I always thought this behaviour was intended (even though annoying). In short: When no tab is connected to the streamlit server, you cannot terminate the streamlit server by pressing CTRL+C in the terminal. You have to open a new tab first. Only then CTRL+C will actually go through.

1 Like

Same issue here

I couldn’t find a current or closed issue talking about this directly, so I went ahead and created an issue in GitHub: Cannot Ctrl+C to end streamlit process from CLI without an open tab (in Windows) · Issue #6855 · streamlit/streamlit · GitHub

1 Like

it worked for me