Hi Liji Jose,
This behavior is expected since the the window is opened using client side code will remain until the page is reloaded /postback-ed or navigated away.
One suggestion is that you can ajaxify the page in order to avoid the postback which in turn remain the window opened after executing server code. Here is the forum
which discusses similar scenario.