Fixing problem in shutdown