set the closed flag when the processMessage goroutine.