Replace synchronuous POST call in beforeUnload handler