I had this problem piping rosettes. It came out stringy.
I think the icing might behave been too soft, or take it out of bag and remix it. I put it back in the fridge in the bag, for a few mins to firm up. Or take it out of bag and remix it.
If that doesn't work, there might be air bubbles in it. Take most of it out of the bag and remix it. Take your small spatula and remove the mess.
But, in my case, I firmed it up in fridge, and it worked. Take your small spatula and remove the mess. Having
Also, having a cold cake or cupcake makes it easy to clean up mistakes.