Close the thread only if needed.
Removed the stats handling since that's not supported in Varnish >= 3.0 anymore.