Otherwise, you might try a miniture relay that only energizes during programming, which connects the positive wire between the programmer and target. Energize the relay with USB power. If you use a diode in the relay's coil circuit that prevents the battery from keeping it when unplugged from USB, then you should disconnect the programmer when USB is disconnected. Just remember, the diode will have about a .7V drop, and so the relay should work from VCC - .7V. If VCC is 3.3V, then the relay needs to work down to about 2.5V. Now, whether or not you can find one in the range is another story.