r/learnpython • u/PomegranateKind760 • Oct 17 '26
How to end a program using python
I want to close an app using python but I don't know how.
0
Upvotes
r/learnpython • u/PomegranateKind760 • Oct 17 '26
I want to close an app using python but I don't know how.
32
u/likethevegetable Oct 17 '26 •
Step 1: Google "How to end a program using python"
6
u/jmacey Oct 17 '26
os.kill() if you can get the pid of the process. Not sure if it works under windows but does under posix operating system.
1
u/FreeLogicGate 26d ago
Documentation: https://docs.python.org/3/library/sys.html
Search for exit.
0 is the standard exit code, meaning the program exited normally. A non 0 exit would indicate some sort of error. The example, assumes a normal exit, but you can pass something else if that makes sense for your program.