Move restart logic outside of "with" statements

By making restarts happen with an exception, we guarantee that cleanup
takes place in the old process before starting afresh with a new one.