Emit 'close' and 'end' events on respective socket events
Change callbacks to use 'function (err, result)' signature
Check for err after logging in, delete completed pending_actions