Verify socket is resource before closing