Fix a bug that socket disconnect didn't terminate properly

Hoping to resolve Issue #64