Fixed shutdown issues.