I took a piece of code from here: https://stackoverflow.com/a/10457565/13882705 which is
# I have used os comands for a while # this program will try to close