Bugfixing invalid stream socket close