Easy way........
Assumes that when power is off that the Air piston closes on the Z (also assumes that on Air failure, your piston mabey has a sping to close it..... fail safe?).
at any rate.......
Your drive that you use for your Z, should have an "Enable" signal for that drive that comes from Mach3, Mach3 puts out up to 6 Enables one for each axis, or you can just use ONE period. AT any rate, when ever mach is loaded up and running, your Enables in Ports and Pins will turn ON, and thus activate also your solinoid for yoru air cylinder to pull it off the coupling.... NOTE: when you push Reset, or mach Estops, the Enables are killed, and thus it would lock your Z then as well...
Make sure that what ever your pulling your enable off of, (ie one of the outputs on the galil board), that you have enough amps to drive the Axis Drive(s), and pull the solinoid, if not, you may need to go through a Relay.
scott