You can use window.onunload (As Gauresh pointed)or window.onbeforeunload (I would prefer) to read the cookie value and trigger the set of code you have. But both are browser dependent i.e. wont work on all the browsers and increase one more server call.
Regarding Form Abandonment, if the user navigates to different page of your site before completing the form, as you said you can store it in a cookie and capture the value in next page correlating the previous page value.
Though we capture the interaction through Data Layer, we need to trigger the Analytics Call while abandoning right? Abandonment may be either the user navigate to other page, close the tab or close the browser. If it is unable to track the close the tab or close the browser, it is upfront that it is not possible to track the abandonment during the instance.
I don't think there is a simple workaround.
Won't recommend for additional Pop-up since we can still close the browser leaving the pop-up open.