Updates to shutdown procedure. It still doesn't work right, but it's better.