if script manager is present in your page the above code you wrote will not work all the time
try this it works fine for me if script manager exist in the page
string script = "<script language='javascript'>window.close();</script>";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script, false);