Fix runtime shutdown sequence.