Here is something I learnt from a StackOverflow thread (unfortunately could not find it to link to this answer):
window.open(document.URL,'_self','resizable=no,top=-245,width=250,height=250,scrollbars=no');
window.close();
This closes the window/tab. It can be characterized as a hack. Essentially, it fools the browser into thinking that the current window is a window/tab opened by JavaScript. Because the rule appears to be that JavaScript can close a window that was opened by JavaScript.
It works in Chrome, Firefox. Internet Explorer needs a little extra treatment to account for varying behavior since IE 6 to IE 8+. I am including that too, if anyone's interested.
            var Browser = navigator.appName;
            var indexB = Browser.indexOf('Explorer');
            if (indexB > 0) {
                var indexV = navigator.userAgent.indexOf('MSIE') + 5;
                var Version = navigator.userAgent.substring(indexV, indexV + 1);
                if (Version >= 7) {
                    window.open('', '_self', '');
                    window.close();
                }
                else if (Version == 6) {
                    window.opener = null;
                    window.close();
                }
                else {
                    window.opener = '';
                    window.close();
                }
            }
            else {
                window.close();
            }