fixed up the shutdown function calling