I’ve had flatworms in my tank for years. Flatworm exit does a good job of killing adults, but there are always more. If you have a coral qt, you may be able to run it at a higher level, and run multiple rounds. Never tried it though.
At this point, I have a couple of wrasses that keep them in...