Literally 'spirit goes out' — your 神 (spirit/consciousness) leaves you, so you stare blankly or are completely absorbed. The same image extends to 出神入化 (chūshén-rùhuà), 'reaching the level of divine artistry.'
grammar
Often used with 看 or 听 in the V-得-出神 pattern: 看得出神 / 听得出神 ('watching/listening so intently as to be lost in it').