Electrical discharges in the vicinity of any microprocessor is bad news. Any wires attached to the micro, whether to the ports or as power supply leads, can act as antennas conducting induced voltages to the cpu. Minimizing wire lengths will help. Thorough shielding sometimes will help. If you still experience problems try connecting schottky diodes from each such lead to +5v and to ground.
I used to design microprocessor controls for ion implanters and x-ray steppers which operated in the vicinity of high voltage discharges. The micros had to be heavily shielded and connected to the outside through fiber optic cables. No direct connections.
Design the software expecting COP to restart the cpu when needed.
If all your efforts fail, consider contacting a consultant from the ion implanter industry. These problems have been solved before.
Regards,
Astro_goto