How can the usage of browser alerts be restricted in a way that doesn’t limit the usage of this feature for positive UX?

How long should remain an email session opened? Yahoo, Gmail, Hotmail. And what’s the best practice to expire it?
I looked up for it but with no luck.
Thanks!