i have used three aproaches... each worked in its own way.
when my son wanted me to stop talking because i wasn't talking to him. I politly asked the person i was talking to to "please Excuse Me?" (showing him how to interupt a conversation politly) then I told him the words he was using were not nice "shut up is not nice, it's RUDE!" so he can put his nose on the wall for 2 min.
My other son was a little older the first time he said it. SO just like curse words I explained to him the diffrence between mommy/daddy/adult words and kid words. only shut up, stupid, and most curse words i explained as not mommy daddy words or kid words they are just rude! that worked for my eldest son on many words. (doing this so i'm not ever banishing a word from his vocabulary... his will exceed mine one day the little brain child!!!! just explaining it as to where it fits in his life at the moment.
then theres the delema of not getting thru at all... like my youngest at first... explaination didnt work, time out didnt work, so I did what he said... and didnt talk to him and cried "because he was mean to me" and if he tried to hug me or ask me whats wrong i told him flat out (only time i would talk TO him) that he hurt my feeling telling me to shut up) and soon he told me he was sorry he said shut up... well in his 3 year old vocabulary "sorry mommy for shut up".... i hugged him and thanksed him and told him how much i liked it when he was nice to me!...
hope any of this helps
A. H