Usually -- they just switch from DC to AC into the coil, which weakens the attraction, and as you pull the workpiece away, the AC field slowly decreases removing the permanent magnetism otherwise potentially left in the workpiece. In the case of mine, it has no spring return, so you can lift the workpiece away at leisure.
Ideally -- you would have a circuit which caused a steadily decreasing AC voltage to demagnetize everything and then just go away. You might be able to do it with just a good quality charged capacitor switched onto the coil, which would ring for a few cycles and this may be what you have with the momentary switch.
Enjoy, DoN.