Modified shutdown() function