fixed some shutdown issues