Properly disconnect shell socket