Scared out of my wits

What are the origins of the phrase "scared out of my wits"?

Meaning, of course, too scared to think clearly. I am wondering if it has anything to do with the belief that in times of stress, a person's soul leaves the body. As in, being "beside yourself."

Replies