I have this same problem with the machines at the gym sometimes. I haven't figured out a solution except to try not to touch the machine accidentally. Which is hard, because I have a tendency to want to run as close to the front panel as possible. I guess I'm unconsciously afraid I'll fall of the back, but there's actually plenty of room for me to move back a bit. I'm so far forward that sometimes my feet even kick the front of it and almost cause me to trip. It's a wonder I don't break my neck.
I guess one thing that works that is that I started bringing a water bottle and setting that in one of the little holders on the front panel. The water bottle sticks up above the front rail, so now I hit the water bottle with my hand instead of the treadmill. The bottle is plastic, so it doesn't carry a charge. So I don't get a shock anymore, but now I'm scraping up my hand on the water bottle. If it's not one thing, it's another.
But that makes me think that maybe a solution would be to a towel or something over the rail or wherever you have a tendency to bump the TM. Something rubber would be ideal, but I can't think of anything rubber offhand.