Handling of publishing socket shuting down remotely. Fix #1