check if socket is actually open before calling shutdown/close methods