Gracefully Shutdown in replit?

How do i make my python code gracefully shutdown when the stop button is pressed or replit quits it in a repl?

1 Like

What do you mean by “shut-down”? Because if all code is ran then the script is done and it will stop running. But if you mean to like kill it then you could try importing os and doing os.system("kill 1")


In Replit, you can handle graceful shutdown of your Python code when the stop button is pressed or when Replit quits the REPL. To achieve this, you can use the atexit module along with signal handling.

No. I’m making my own sqlite3 encryption i need it to decrypt it when starting and encrypt it back after exit

Can you give me a example?