Persists state to local storage