I\'m using the Firefox Webdriver in Python 2.7 on Windows to simulate opening (Ctrl+t) and closing (Ctrl + w) a new tab.
You can choose which window you want to close:
window_name = browser.window_handles[0]
Switch window:
browser.switch_to.window(window_name=window_name)
Then close it:
browser.close()