Fail gracefully if localStorage is not accessible.

Based on PR from @darbs.

Fixes #365