Fixing shutdown issue