Socket cleanup fix