Help reliably reading switch on long wire

I agree that polling could potentially cure this but it may affect the operation of the machine as it will have to poll the switch multiple times before it is "sure" it is closed THEN stop the motors moving it towards the switch.

Depending on hw timings you could just digitalRead() the switch state twice, 5 to 20 ms apart. That's what I did on a project of mine with a stepper motor. But it was moving "slowly".