Close database and cursor properly