Fixing shutdown sequence.