catch socket close event as well