I am quite the beginner at python (and programming altogether), but I'm attempting to learn (slowly but surely). Anyway, I am attempting to make a standalone python program that will interact with firefox (opening links, etc.). I've figured out how to open FF and open links. However, for the life of me, I cannot figure out how to close it again. I used os.spawnl(os.P_NOWAIT, "c:\\program files\\mozilla firefox\\firefox.exe") to open FF. I then attempted to use win32api.TerminateProcess(396,0) to close it again, but I received the error: error: (5, 'TerminateProcess', 'Access is denied.') . I am guessing that FF is blocking my TerminateProcess command(?). MSPaint will start/shut down fine using this method, but the Any ideas to prevent FF from blocking my command or ideas about other methods to shut the program down? Thanks for any and all help!

This question has already been answered. Start a new discussion instead.