localStorage can be cleared at any time anyway. This simply makes it happen on each page navigation.
IDK what you'd rather do in Chrome Incognito, Safari Private, Edge InPrivate, etc.
---
PS. If the OS registry entry for localStorage location is invalid or missing, IE will also throw an error.