added soft shutdown code