Added cleanup before exiting on socket error
_perror has now the same format as _log