Monitor browser tabs with localConnection and sense when a user closes a tab

In my application the browser window connect with long polling(comet) with the server. If the user open several browser tabs, only one of them(called the master) communicate with the server and serves as a proxy for the other tabs. I want to use flash localConnection to exchange data between the tabs.

What happens when a user closes the master tab that holds the comet session? I can use javascript with the unload event to inform the other tabs that the master tab is closing and then close the localConnection but the unload event is unreliable. I can use polling to monitor the master tab connection object but it sound dirty.

When the master is closed one of the other tabs need to become the master. How do I make sure only one of them tries to become the master?

If a user close the tab without flash being able to close the localConnection, will it cause a memory leak?

Thanks