Ensure connect callback is invoked on premature socket hangup

Closes #534