Afghan spy chief quits after denouncing talks with Pakistan