Close database, fixes