if you write webbrowser.open after httpd.serve_forever, httpd.serve probably blocks the execution and webbrowser.open is never executed. That's why you are not seeing browser. You can put a print after httpd as experiment, it should never print.
webbrowser.open starts a browser in a process that is different from httpd.
So when you close webbrowser, nothing will happen to httpd.serve_forever(). Like the name suggests, httpd.serve_forever() will serve the http server forever until you manually kill it by ctrl+c or some script like kill -9 .