Wednesday marks the 18th anniversary of 9/11. On that day, terrorists killed nearly 3,000 people in attacks against the World Trade Center, the Pentagon, and on Flight 93.

The U.S. mindset irreversibly changed that day. No longer did we perceive a world largely at peace following the end of the Cold War. Instead, evil came and found us.

The warning signs had been there for years. The World Trade Center was first bombed in 1993. Also during the ’90s, U.S. embassies and military assets overseas had been attacked.

The Taliban had sunk Afghanistan into poverty, violence, and religious persecution and was already known to provide a safe haven for al-Qaeda. We even knew some of the men who would become 9/11 hijackers and had bits of information about them and their possible activities.

Since that fateful day 18 years ago, we have revolutionized the way we combat terrorism.

The government has invested significantly in intelligence programs to find and stop terrorists, both at home and abroad. We’ve created new government agencies—most notably the Department of Homeland Security—to carry out a variety of security functions.

Counterterrorism is now one of the FBI’s primary tasks. We have fought long wars and run counterinsurgency operations to deprive terrorists of a sanctuary to train and plot future attacks.

Two lessons stand out above the rest: Law enforcement and intelligence agencies must work together to thwart terror at home, and we must deny safe spaces to terrorists abroad.

Yet over time, there is a tendency to forget these lessons.

Take for example law enforcement cooperation and information sharing. The FBI has set up Joint Terrorism Task Forces across the country. These are groups of federal, state, and local law enforcement that work together on counterterrorism.

These task forces have carried out countless investigations and arrests of terrorists who would have done our country harm.

But San Francisco and Portland have recently chosen to withdraw from their task forces to score political points, putting their citizens in harm’s way.

Similarly, when Congress debates various intelligence programs, it should be careful to avoid putting up barriers or weakening our capabilities in ways that will slow the sharing and use of critical information.

Abroad, some Americans would prefer we stop engaging in costly wars—and understandably so. That desire is perfectly illustrated by recent discussions over a potential deal with the Taliban and the withdrawal of troops for Afghanistan. (That potential deal has fallen through for now.)

Of course, we should be willing to negotiate an end to conflict if we believe it might actually result in lasting peace. But if we just walk away and signal that we want out at all costs, we send the Taliban and others a message: that they can return to their malicious activity unabated.

That’s a bad deal for American security, and a bad deal is worse than the status quo.

Let’s be attentive to these lessons in the fight against terrorism moving forward. They will serve us well, and they’re the best way to make sure 9/11 doesn’t happen again.