Method check close status of tab Error When check with link Google search

var link1="https://www.google.com/search?q=marketing";
//var link2="https://stackoverflow.com/";
var tab=window.open(link1,"_blank");
setInterval(function(){checkTabsClosed()},3000);
function checkTabsClosed()
{
if (tab.closed)
    console.log("close");
else 
    console.log("open");
}

When I user link2, it is ok. But I user link1, it is not ok.
Please help me code to check tab in this case link1.