Disable KM web server via macro?

Hi,

For security reasons I'd like my laptop to automatically disable the KM web server when I leave my home network. I couldn't find a way to do that neither via a defaults command nor AppleScript. Is there any way to do that before I resort to System Events GUI scripting?

Cheers