I want the page url to redirect somewhere when the popup

I want the page url to redirect somewhere when the popup is closed (either via the X button or clicking in the background).
How do I achieve this?