[bugfix] close sockets properly on errors