fixing shutdown procedure