What you seem to be blissfully unaware of, is that extremists move from one area to another. If one neighborhood becomes less suitable for their activities, they move to another. Of course, they keep their covert activities under the radar as much as possible, so as not to bring unwanted attention. They also tend to operate toward a common purpose under a variety of names and leadership and in many places.
Anti-Western extremists, terrorists, and zealots have been around for decades under a variety of names in a variety of places. There were several in Afghanistan before the invasion 20-years ago. Many simply migrated to other places like Pakistan, the mountain border regions, Syria, Iraq, Somalia, Yemen, etc. They've never been defeated—not by Russia, the U.S., Bush, Obama, Trump, or anyone else—because it's an extremist ideology that is the root which binds the branches of terrorist groups and not a group's name, leader, or place that unites them in their efforts. Push them out of one place and thy show up in another. Their ideology has no boundaries.
Did the Taliban or their predecessors leave Afghanistan or simply harass, hit and run with attacks, and wait out first the Soviet and then U.S. forces thru attrition? Did
Al-Qaeda ever go away or did they just change names, leaders, affiliations, and locations?