Improving handling of shutdown (highest priority).