Implemented shutdown procedure.