Or if you just want to block the flag from being put into an area, use a func_respawnroom. Yes, that's the only entry that both dettaches the flag and doesn't kill the carrier.
But if killing the carrier isn't a problem, there is a func_respawnflag entity to combine with trigger_hurt.