We show that the length of the alkyl chain of surface ligands can shift the equilibrium between the wurtzite and zinc blende polytypes of CdSe nanocrystals. In-situ wide-angle X-ray scattering measurements reveal that short-chain (e.g., propyl) phosphonic acids stabilize CdSe nanocrystals with the zinc blende phase whereas octadecylphosphonic acid stabilize nanocrystals with the wurtzite phase. We also demonstrate how this effect can be used to improve the shape selectivity in the synthesis of anisotropic CdSe/CdS and ZnSe/CdS nanoheterostructures.