Fix disconnect socket closing to make it work with java 8