Stop script when there is error

I have also tried

st.stop()

&

raise st.ScriptRunner.StopException

None of them works for me.
Any suggestion would be appreciated.

streamlit --version
Streamlit, version 0.62.1