Fix crash when closing preferences

http://ankidroid-triage.appspot.com/view_crash?crash_id=6738282016669696