To test this, ensure that you open the live site and move your mouse out of the viewport towards the top of your browser. This also sets a cookie to prevent the modal from continually loading with each new visit. So, to test either clear the cookie or open incognito.
I threw this cloneable together based on the guide provided by webtips.dev (GitHub). Check out their site for additional features or adjustments to the exit algorithm.