Added a try/catch around writing the database out to disk to fix an intermittent bug