The workpiece is normally located with a fixture / dowel pins for repeat work to make sure the workpiece is always in the same position.

Assuming you are at least doing that, and you are cutting metal, then using microswitches and prox sensors might be possible but it is difficult due to contamination from metal swarf and coolant.

Another option is to monitor the current from the spindle supply and if the part is loose or falls out of the fixture and you are cutting air, then the current will be low. You would probably need some sort of interface device to check that the current stayed low for a certain period before feeding a fault signal into your controller and pausing the machine.

A picture of the problem, and the cnc machine you are using may for further ideas.