What does "三魂去了两魂半" mean? It's used to describe an expression so I guess it's close to being shocked or frightened from the context it's used in but I don't really understand why it means that. 

So a detailed explanation will be much appreciated.
The expression is somewhat similar to English scare the living daylights out of somebody, with many variations. A quick Google search shows


三魂[少/去/嚇飛]了二魂
三魂剩下半魂
三魂去二


and other similar constructions.

三魂 refers to the three hun in Chinese philosophy/folk religion or Daoist belief. The three hun make up a person's "essence" (soul, spirit) when they're alive, and go their separate paths after a person passes away:


One hun returns to the primordial universe from whence it came;
One hun faces judgement for the person's good and bad wordly deeds in hell;
One hun resides at a person's burial place or ancestral tablet, and is the hun that is passed on to a person's descendants.


If the three hun are somehow absent from the body when the body is still alive, then the body becomes a walking corpse (行尸走肉), so the expression 三魂去了兩魂半 means almost frightened to death.