It wasn't boots on the ground that fucked up Iraq and Afghanistan. It was the fact that we had no government to take over. In Afghanistan, there is none. On Iraq, we had Saddam. Brutal as he was, he didn't allow this element to carve out a state in his domain. In Iraq, we were dumb to sack everyone involved with the previous administration. Those unemployed government officials started the insurgency.
In Syria, we have Assad. Reinstall him, as Russia is attempting. Kill Isis. It cannot survive with the death of their caliph, Al Baghdadi, against Assad with western backing. That's how Isis can be stopped. They are not a shadowy guerilla group. They are a real state with towns and checkpoints and materiel.