Protect against localStorage write failures.