socket closing procedure added