adding synchronous calls to support onbeforeunload