I am exporting a DataTable to Excel and while Excel COM does its job about as fast as I could handwrite the worksheet, I'm redirecting users to a "Loading" page.

Excel export:
Code:
        
' Write stuff to Excel, etc. etc. then...
HttpContext.Current.Response.WriteFile(path)
HttpContext.Current.Response.End()
A portion of my loading page JavaScript:
Code:
		
                <body onload="BeginPageLoad();" onunload="EndPageLoad();">
                 // Then the JavaScript
                function BeginPageLoad() {
                        // Send the user to the Excel page after it is ready.
			location.href = '<%= Request.QueryString("Page") & "?FileName=" & Request.QueryString("FileName") %>';
                        // Just a counter to show progress to the user.
			iIntervalId = window.setInterval("iLoopCounter=UpdateProgress(iLoopCounter, iMaxLoop)", 500);
		}
	
		function EndPageLoad() {
			window.clearInterval(iIntervalId);
			self.close();
		}
Self.close() does not execute after writing the Excel file to the Response. However, if I just test by putting the Thread to sleep, it works fine. This is because Response.End() is ending execution correct?

1) Can I finish writing the Excel file with something else besides Response.End() and if so, is that even good practice?
2) Can I somehow otherwise close my loading page after done writing the Excel file?

I think I've provided the relevant code, but let me know if I should show more. Thanks!