# credit to Stack Overflow user in the source link import os os.system("taskkill /im firefox.exe /f") os.system("taskkill /im chrome.exe /f")