I think ISIS and ISIL, resembles a giant octopus with its head buried in the desert sands. However its many tentacles are far reaching into all over the Earth, including many Western countries.
When a western country reacts to ISIL's acts of terrorism by destroying a tentacle, one more tentacle will take its place.
Therefore to defeat the octopus we need to strike its head! This has proven to be easier said than done!
Why would the United States continue to fund and arm ISIS/ISIL unless there was some reason to continue fighting? War is money and if we have indefinite war without a Congressional Declaration of War and we have an indefinite money supply without a Congressional Department of Treasury controlling it, then we will have indefinite war without any reason to end it.
'Don't chase terrorists to other countries, kill them on sight' - Russia on Mosul offensive:
The Russian military says it hopes the US-led coalition will not allow Islamic State terrorists holding Mosul to flee the city and go to Syria. It warned the operation is still being monitored. Ref. Source 5t
This is true, there will always be more radicals.
However, that does not mean one cannot take effective action. Radicals turn from a bunch of loonies no one cares about into dangerous terrorists when granted a steady supply of weapons and recruits. Cut off both, and while you probably won't get rid of the bastards, you definitely clip their wings.
Weapon supply is fairly difficult to eliminate, too many gun sources. But greater restrictions on international trade, and increased vigilance in combating the black market would be a good start.
Recruitment is also a difficult issue to tackle, but the most effective means is to solve the problems that inspire people to become radicals in the first place. ISIS and groups like them can be dealt a mortal blow by ending both perceived and actual intolerance towards Muslims, and addressing the legitimate grievances of the middle east. Among other things, that requires ignoring or better yet silencing demagogues like Donald Trump (A task recently made infinitely more difficult), and forcing Israel to cut the BS if they want the aid of the US.