The Islamic State keeps losing ground in Iraq and Syria. But defeat wouldn't mean the end of the terrorist group. Here's NPR national security correspondent Greg Myre.

GREG MYRE, BYLINE: Nicholas Rasmussen, head of the National Counterterrorism Center, says the war against ISIS is going well on the battlefield. Military campaigns keep chipping away at the group's territory. New recruits are way down.

(SOUNDBITE OF ARCHIVED RECORDING)

NICHOLAS RASMUSSEN: The good news is that we know that this rate of foreign fighter traveling to the conflict zone has steadily declined since its peak in 2014.

MYRE: This is forcing him to think about how ISIS will evolve as it loses most - or perhaps all - of the land that it rules.

(SOUNDBITE OF ARCHIVED RECORDING)

RASMUSSEN: We expect that the numbers of foreign fighters attempting to leave Syria and Iraq - they will increase as ISIS continues to lose territory.

MYRE: National security officials here and abroad were initially concerned they could be flooded with returning ISIS militants. An estimated 40,000 foreign fighters from more than 100 countries have gone to fight for the group. The largest concentrations are from Europe and other Middle Eastern countries.

(SOUNDBITE OF ARCHIVED RECORDING)

RASMUSSEN: But I think we've come to realize that it's actually quality that matters as much or more than quantity when it comes to foreign fighters who are returning home.

MYRE: He says the greatest risk is now expected from a relatively small number who have skills to carry out sophisticated attacks or to recruit fellow extremists. Still, Rasmussen believes the U.S. has better position than most to guard against them.

(SOUNDBITE OF ARCHIVED RECORDING)

RASMUSSEN: And that's because the U.S. persons make up a very small portion of the total number of foreign fighters.

MYRE: He didn't give a number, though other U.S. officials have previously said about 250 Americans have attempted to join the Islamic State. ISIS is also calling for supporters in Western countries to carry out attacks, even if they never left home and don't have formal links to the group. Several recent attacks in Europe seem to follow this model. Rasmussen acknowledged there are plenty of threats inside the U.S. He says the FBI is investigating about a thousand potential cases of homegrown extremism.