Close database before corrupting it