Can you end a coroutine from outside of that coroutine?

I'm not exactly sure how else to word this question, so the way I titled it may be inaccurate.

But basically, I am running an AI that is a basic finite state machine with an ienumerable with a few different states, and I do a bunch of checks to see which state the AI should be in, set the state, then do a switch on the state and perform whatever action is associated with that state (a coroutine, like (yield Wander(), yield Chase(), yield Attack(), etc). But inside each of those coroutines, I have to basically do the same check I did that got me in this state in the first place, to determine when I should return and get out of it.

I wish I could just somehow have the check I originally did running simultaneously the whole time, and could switch the states even when the AI is in one of the coroutines associated with a different state. Is something like that possible?

Have your coroutines do something like -

function AttackCoroutine() {
  while ( state == Attack ) {
   // do stuff
   yield;
  }
}

function PatrolCoroutine() {
  while ( state == Patrol ) {
    // do stuff
    yield;
  }
}

Then your main AI-choice-decision-thing can just set state to the desired state and start a coroutine; the others will gracefully break out then.

if ( state != Attack && playerIsCloseEnough ) {
  state = Attack;
  StartCoroutine( AttackCoroutine ); // or however it is you invoke coroutines
}

If you have to stop a coroutine, then if you start it by name (string, not method call) you can also stop it by name.

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.StopCoroutine.html

Unfortunately this will stop all running coroutines with that name (for the current instance of the MonoBehaviour, not all GameObjects running the behaviour).