I've read that it's possible to make this through AJAX technology. I.e. you create a special web-page that 'listens' to your program at 127.0.0.1 and acts accordingly. I.e. you can close the page by sending a kind of 'window.close()' script through AJAX. That'd work only for specially created local pages, however, it might also work to close external pages/tabs.
However, I didn't analyze this stuff too deeply, just as a basic concept.