fixed shutdown when multiple connections exist