I'm using a mac, so that's all I can refer to here.
Check out a free app called Proximity. It monitors whether a bluetooth device (your phone) is within bluetooth range or not & can trigger applescripts when the phone is both in and out of range of the host computer.
I have applescripts to open icamsource when the phone is out of bluetooth range and quit icamsource when it's within bluetooth range & it seems to be working well.
Just make sure Autostart is checked in icamsource preferences.
Hope this helps.