try cursor.close first, then self.close