don't let socket be closed twice