Here the word "him" refers to the demon-possessed man.
"and cried out with a loud voice as it went out from him"