Attempt at handling Shutdown properly.