this probably isn't possible, i've used onbeforeunload, to load a image on a server, which is actually a php script
or at least if it does work will be browser specific, as chrome like to block x-script and ajax calls on the onbeforeunload function, would expect it to pull the memory from the flash instance too
However something very close should be possible
if possible move your logic into javascript, use the grab image hack for server side communication, and return a string to pose the user a "Are you sure you want to quit this excellent page?" style question
ps i don't mean rewrite everything in javascript, just maybe poll from javascript what the user is doing, so when the user closes the page, the javascript can go "But your currently editting your awesome XXXXX image ?" where XXXXX was the last thing javascript polled from as2