Fix SQLite errors on logout