Jet formation in the transition from the asymptotic giant branch to planetary nebulae