Closing the new tab automatically

Hello dear community,
I implemented a slight change to a function to achieve the automatic closing of an opened tab. I did achieve the wanted outcome, but I still cannot figure out the difference between the implementation I wrote, and the original implementation. Basically, when the user clicks the download as (exporter) option in the notebook, a new tab is opened; this tab is not closed automatically after the notebook is exported. Ideally, we want to close the tab automatically after the conversion is done, I could achieve this by making a slight change to the _new_window() function in the menubar.js module. Here is the original implementation and the new implementation of the method:
Original: Does not close the tab automatically:

MenuBar.prototype._new_window = function(url) {
        var w = window.open('', IPython._target);
        if (this.notebook.dirty && this.notebook.writable) {
            this.notebook.save_notebook().then(function() {
                w.location = url;
            });
        } else {
            w.location = url;
        }
    };

New: The tab is closed automatically

MenuBar.prototype._new_window = function(url) {
        if (this.notebook.dirty && this.notebook.writable) {
            this.notebook.save_notebook().then(function() {
                window.open(url, IPython._target);
            });
        } else {
            window.open(url, IPython._target);
        }
    };

Please do you have any idea why the first implementation did not close the tab? And what makes the second implementation different. Thank you,