added some shutdown code