driver.switchTo().alert().accept();//close alert
или
for (String winHandle : driver.getWindowHandles()) {//Jump to new tab
driver.switchTo().window(winHandle);
}
driver.close();//close tab
for (String windowHandleId : driver.getWindowHandles()) {//come back
driver.switchTo().window(windowHandleId);
}