I recommend this solution :
Don't use response.End();
Declare this global var : bool isFileDownLoad;
Just after your (response.Write(sw.ToString());) set ==> isFileDownLoad = true;
Override your Render like :
/// AEG : Very important to handle the thread aborted exception
override protected void Render(HtmlTextWriter w)
{
if (!isFileDownLoad) base.Render(w);
}