by closing the socket. try using socket_ functions in php. example here http://www.hawkee.com/snippet/6076/
by the way killwithme, if you launch the script with a .bat file it uses cmd.exe as the bot window.