Change the USB settings on the phone from “mass storage device” to “charge”; this will stop the phone from automatics on the PC. This will not affect adb, which uses a different mechanism to talk to the phone. Then you can just pull out the plug whenever you want.
(If you leave it in “storage device” mode, you can damage the file system on the SD card when you pull out the plug. In addition, the application you are working on will not be able to access the SD card anyway.)
source share