public function handleClose()
{
$this->pause();
if (is_resource($this->resource)) {
// http://chat.stackoverflow.com/transcript/message/7727858#7727858
stream_socket_shutdown($this->resource, STREAM_SHUT_RDWR);
stream_set_blocking($this->resource, 0);
fclose($this->resource);
}
}