This is usually down to the oil and fuel mixture you have in the tank. If the mixture is too rich, the engine will load up and die at idle speed. If, on the other hand, the mixture is too lean, the engine will be starved of fuel and cause it to surge or rev highly. Both mixtures are wrong and will cause your chainsaw to die.