Fixed the shutdown problems.