Connecting/dissconnecting a motor from a VFD or stepper controller when it is powered is generally considered a risky business due to the voltage spikes that can occur. Power transistors have been described as 'the fastest fuse on three legs' for good reason. If your switch has a back contact that can be used to prevent the VFD from trying to start when the motor is not connected that might be a good move.