Fix handling of return code from shutdown