MANTA-2315: Simplify socket error/close events

Certain socket conditions were causing 'error' events to go unhandled,
potentially due to improper ordering in the cleanup logic.