Is this just proactive chat which snapengage already offers?
Targeted chat lets you take a variety of actions other than just automatically starting conversations (label visitor, hide chatbox, show chatbox, route to operator/group) based on a wider variety of conditions about the user (too many to list here).
Take it for a spin and let me know if you have any more questions! Always happy to help.
From the demo, they offer a rule based on referring and current URL (you may be able to use this in order to determine if a user has already pressed back). Nothing I can see regarding closing the window, your best bet may be to use the given example: "number of seconds user is on page".