Move sweepClosedSockets() to sockets.js

I wasn't able to produce any results using this, but it didn't cause any bugs either, so might as well.