In order to sync local data with server, it would be useful to have an event that is triggered when the user leaves / closes a website. It is already possible to detect when a user leaves a page using the Page Visibility API, however it is not possible to detect the end of session (e.g. expiration of sessionStorage).
This event would allow developers to save data changes locally and collect website analytics (e.g. performance, tracking, user preferences) inside sessionStorage (or localStorage) and then send the data to the server only once, at the end of the visit, instead of creating an additional HTTP request for each page view.