I'm late to the party, but I want to provide some additional comments. It's helpful when considering ESD and EMI effects to go back to the basics of circuit analysis or maybe even electromagnetics.
Let's consider the case where your electronics are in an enclosed metal chassis. Suppose there's a large potential voltage between the chassis and some other device. In that case, the potential will equalize when the device or material is close enough to contact the chassis or create a dielectric breakdown (arc). Then the electrons on the surface of one of the devices will flow to the other to evenly distribute the charges. This flow of charges can be measured as a current, and the current will generate a voltage across segments of the chassis that is related to the resistance (or conductance) of the enclosure. Higher currents and/or higher resistance means more power dissipation and more heating.
If for some reason, the resistive path through your electronics is lower or on the same order as your enclosure, the current will flow through your electronics. This can be avoided, however, if you only connect your electronics to the chassis at a single point. This way, fault currents on the chassis cannot flow through the electronics. We call this a single-point grounding scheme (SPG). Using SPG is very common in high-reliability applications such as industrial or aerospace settings for this exact reason. I won't go into this now, but it's important to know that SPG is not the best grounding scheme for all applications.
For your application, if your device is in a conductive enclosure, and has an SPG, your ESD concern should already be pretty low. However, ESD is not the only thing you should be considering when it comes to the safety of your electronics. Industrial environments are notorious for high EMI, including low-frequency fields generated by motors, generators, etc. These low-frequency fields can penetrate your enclosure and interact with your electronics.
If your MCU inputs are floating, any EMI on the pins can adjust the voltage to create spurious signals that could cause unexpected behavior, or even worse, damage. This is a bad idea.
If your MCU inputs are tied directly to ground, these spurious signals cannot change the signal on those pins relative to ground, and your inputs and software functionality are safe. However, if your software/firmware is not yet tested, these inputs could accidentally be configured as outputs and driven to levels that may cause damage if there is no other fault protection. Such faults could also be a concern in environments where single-event upsets are a problem (e.g. a bit flip in the control register for an unused pin set the pin to an output high level). This could be a problem whether you intend to configure these pins as an input or an output driven low.
If your MCU leaves these pins as floating inputs with an internal pull-up or pull-down, EMI is not likely to have any effect on them when the board is powered on and running, but you will want to pay attention to the reset state of these pins. When your device is in reset, the I/O may be configured differently than you've programmed.
The overall safest method for terminating unused I/O then is to tie each pin to a resistor to ground and drive the pin as an output low. This protects against EMI and fault conditions in all cases we've discussed here. If the resistor is large enough, you shouldn't see much power consumption, even during fault conditions. If the resistor is too large, the EMI can still couple to the pin and the charge on the pin may accumulate faster than it flows through the resistor, still causing unwanted behavior.
There's a trade-off here that needs to be made, and you should do your homework to ensure you make the right choice. No solution works best for everything. The resistor pull-down may be the safest, but it's not the lowest power, and it's not the most cost/space efficient. Most other methods are safe enough most of the time. What if you have 100 unused I/O? Should you tie each pin to a resistor to ground? As with almost every question I get related to EMC, the answer is "it depends!"
I have never encountered this practice
- this concerns me because this is very much standard practice not only in this specific industry but all of electronics design. You only ever leave pins unconnected if you've considered it carefully and know it's OK or if it's documented to be OK to do so. Maybe these days it's not as bad with LED lights but I've personally fried several personal projects in my youth by just turning on the lights (we mostly use fluorescent lighting in my country and the initial blast of high voltage generates significant noise in nearby circuits) \$\endgroup\$