Instead of running the command from the shell with only the name of the command, run it with exec , which will force the shell to replace itself with the program. Then, when the program exits from the terminal window, it will also close.
those. instead
$ python ./my_script.py
mileage:
$ exec python ./my_script.py
source share