Fixes shutdown hook problem when stages crash

As mentioned in #161, stages do not properly restart more than once. This fixes that bug.