Here is a simple answer that will launch, track, and terminate a new Chrome browser instance, but with child tabs too.
It launches a new process for a Chrome instance, launches additional tabs into that new Chrome webbrowser instance, and finally using "terminate()" when finished to close the original browser launched by the subprocess() and its webbrowser child tabs. This works even when there is an existing Chrome browser process running.
The standard path (user below) for Chrome.exe on Windows 10 is (usually): "C:\Program Files\Google\Chrome\Application\chrome.exe"
The code should always open a new Chrome window, even if Chrome is already running. The package "subprocess" is mandatory instead of os.system, or else it will not launch a new chrome window.
Advantages of this programmatic approach:
(1) subprocess() has a process ID, useful to track and close the browser started in the subprocess.
(2) All child tabs started within the subprocess.Popen() will be closed when the parent subprocess is terminated.
N.B. If there is an pre-existing browser instance running, my_chrome_process.terminate() will NOT terminate it; it will terminate only the instance started by the subprocess.Popen() code below. This is the expected behavior.
import subprocess
url1 = r'https://www.python.org'
url2 = r'https://github.com/'
url3 = r'https://stackoverflow.com/questions/22445217/python-webbrowser-open-to-open-chrome-browser'
url4 = r'https://docs.python.org/3.3/library/webbrowser.html'
chrome_path = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
my_chrome_process = subprocess.Popen(chrome_path, shell=False)
print(f'Process ID: {my_chrome_process.pid}') # Uncomment this line if you want to see PID in Console.
import webbrowser
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open_new_tab(url1)
webbrowser.get('chrome').open_new_tab(url2)
webbrowser.get('chrome').open_new_tab(url3)
webbrowser.get('chrome').open_new_tab(url4)
my_chrome_process.terminate()
If for any reason, my_chrome_process.terminate() does not work, then use the following os.system() code to kill the browser started using subprocess().
See popen.kill not closing browser window for more information.
import os
os.system("Taskkill /PID %d /F" % my_chrome_process.pid)