So this is what the manual says:
Triggered when the page's visibility changes, or when a mobile app is going in to the background or foreground. When invisible or in the background the app is suspended: all events stop running and all audio is muted.
So it wouldn't be triggered when closed. There is no on closed action, because browsers don't support it.
However, what you can do is store the time in webstorage on every second. That way you know the time when the game was closed when opened.