You can close tabs in a browser that are associated with a specific domain like "foo.com" using the following JavaScript code

function close_tabs(domain_name)
{
	// get all the open windows
	var windows = window.open('', '_blank');

	// loop through all the open windows
	for (var i = 0; i < windows.length; i++)
	{
		// check if the window's URL includes domain_name
		if (windows[i].location.href.indexOf(domain_name) > -1)
		{
			// close the window
			windows[i].close();
		}
	}
}

close_tabs( "foo.com");