Fix deadlock in agent representation

Deadlock when try to Schedule task "foo", and receive two updates one after another from the agent:
<- update {"foo": stateRunning}
<- update {"foo": stateFailed}

Block when try to signal "outstanding" containers.

Fix: do not stop listening on channel till it's not closed.

@peterbourgon @jmyounker @stuartnelson3
A comment with some background on what happened before, and how this test helps to prevent that would be useful.