Remember that Flex runs in the Flash Player in the browser.
The main app never really unloads.
do what you want. Is your "clean-up" work inside the Flex app? If
so, and you can catch an early enough event ( "onBeforeUnload" ?)
from the browser, you can use myPlayerInstance.setVariable() to
invoke some action in the Flex app.