Fixed connection bug in Node 11

This fixes how connections are shutdown, npm test now works fine in node 10 and node 11.