Shutdown subprocesses before waiting.
Fix TASK_FAILED/TASK_FINISHED interleaving.

Because wait() and the observer can be running at the same time, it's hard to
say who will finish first.
Set deadline for runenr and observer.

If these go over, Deimos would never terminate.