Jihadists thrive in Afghanistan and in eastern Syria when the Kurds retreat to their barracks.