You should understand the difference between driver.close() and driver.quit()
driver.close() and driver.quit() are 2 totally different ways for closing the browser session in Selenium WebDriver. Understanding both of them and knowing when to use which method is important in your test execution.
driver.close() – It closes the current browser window on which the focus is set.
driver.quit() – It essentially calls the driver.dispose method that successively closes all the browser windows and ends the WebDriver session graciously.
You should use the driver.quit() whenever you want to end the program. It will shut all opened browser window and terminates the WebDriver session. If you do not use the driver.quit at the end of the program, WebDriver session won't shut properly and files wouldn't be cleared off memory. This may result in memory leak errors.
In your case, you have to use the driver.close() which will close the current window and keeps driver active.
Just to add - if there is only one browser window open and you use the driver.close(), it will quit the webdriver session. The webdriver will not stay active.
To know more about Selenium, you can go through the Selenium course page by Intellipaat
Watch this video on Selenium Tutorial for Beginners