1054. better auto shutdown logic

This closes #1054.  It also tidies the auto shutdown logic, and (in a separate commit) does some whitespace style rectification. 
It is no longer possible for a succeeded task to have not spawned.