You should be using quit()
to terminate the process instead of close()
.
As you have discovered, close will close the current window (and browser), but it will not shut down the process. This is useful for if you are going to send additional commands to the process or want to inspect the process.
Quit is for when you want to close every window and stop the process, which sounds like what you are looking for.
The documentation for these two methods reads:
close()
Close the current window, quitting the browser if it's the last window currently open.
quit()
Quits this driver, closing every associated window.