To achieve this, you can create an on_click interaction on a link that leads outside, then use Javascript to delay the effect of the link so that your interaction has enough time to play. You can then set the interaction to target all items of the same class, and you add this class to all concerned links.
Not as straight forward as if there was a when leaving the page trigger I reckon.