They can definitely hide in the population. Rakka still have 200,000 people living there. I have no idea which part of that population are hardcore isis member : 40-50k maximum maybe. Assuming you could take Rakka, you can't just execute or deport every one with a weird accent. Mosul is even bigger.
How many ground troop would it take to occupy all these cities ? This would be a repeat of the second Irak war, or Afghanistan, with the endless terrorist attacks, IEDs, etc.
Even if you have contributions from Kurds, Irak regular army, or Hezbollah, they would not be welcome as savior in Sunni's territory.
Like in most conflict, the military option can be used to create conditions for a political resolution, but you have to provide some sort of long term plan for Sunni population : you can't just tell them they will go back under Assad rule they despise in the first place. Currently, I don't believe there is a clear political solution. In this condition, the military option is doomed to fail.