Generally you have no control over when tab is closed and when flash/flex application is destroyed. So you should not attempt to take any actions on such event, since they may be easily preempted and your deinitialization logic would be disrupted.
In your case (closing connections) you should note that all connections are closed automatically upon application destruction by Flash Player.
Edit: Actually there is a way to catch page unload event in some cases (see the other answer). But there is no guarantee that such methods will always work (i.e. they may not work on browser application close), therefore you still should not completely rely on them.