Stop or Cancel button

Hi,
This solution only works in linux but in windows I get this error.

ctx None
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="mp_main")
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "F:\codes\python\kiha_app\work_with_stop.py", line 15, in <module>
state = SessionState.get(pid=None)
  File "F:\codes\python\kiha_app\SessionState.py", line 69, in get
current_server = Server.get_current()
  File "c:\users\mohsen\anaconda3\envs\tf_gpu\lib\site-packages\streamlit\server\Server.py", line 165, in get_current
raise RuntimeError("Server has not been initialized yet")
RuntimeError: Server has not been initialized yet