It sounds like your limit switches are turning off the power when they are activated. Stepper motors hold their position when they're powered up, but when they lose power they will let the axis loose. If it's a Z axis with a heavy spindle, that will backdrive the screw and drop it to the table. If this is a stepper-powered machine, I'd suggest disconnecting the limit switches until you've got everything else working correctly. Unlike servos, steppers won't burn up from pushing against a stop. You don't really need limit switches at all on a machine like that, as long as it has a stop to keep the axis from overshooting and falling apart.