Here's how to close a popup alert in C# with Selenium:
IAlert alert = driver.SwitchTo().Alert();
// Prints text and closes alert
System.out.println(alert.Text);
alert.Accept();
or
alert.Dismiss();
according to your needs.
Another way you can do this, is wrap your code inside a try-catch:
try{
// Your logic here.
} catch(UnhandledAlertException e){
var alert = driver.SwitchTo().Alert();
alert.Accept();
}
// Continue.