To show the popup when the user tries to leave your page follow this guide.
Go to: “Triggers” > On Exit Intent.
Finally, enable the option “Status”.
Show the popup only the first time.
Enable the cookie to display the popup only once, once the user closes the popup, they will not see it again until the cookie expires.
Live Example: To run the popup like the following image just try to exit the page.