changes for correct shutdown...