fix database not closed error