I'm no expert, but my guess is that the socket has some kind of PID file created when you open it...or perhaps a buffer file to hold socket data waiting to be read. If your program halts without closing the socket (you should avoid this at all costs...maybe a try/catch/finally block?) then that resource file may still exist.
I have no idea where said PID or resource file might exist or whether it's safe to delete it.
Have you tried echoing the resource id of the socket opened in your script? If you knew what it was, you might be able to write a separate utility script expressly for closing the socket. All it would do is call socket_close() using the resource id supplied by the socket creation code. I have no idea if this will work.