According to WebMD, Aha moments, those sudden insights that leave you thunderstruck and wondering why you didn't think of them earlier, are marked by sudden intense electrical activity in the brain known as the right temporal lobe. Researchers of Aha moments even suggest that closing one's eyes helps offload sensory processing and may help Aha moments to manifest. However, that is dangerous territory for me as that might well stimulate the portion of the brain associated with sleeping.
Scientists aren't really sure yet exactly what causes the high-frequency burst of brain waves just before the the Aha moment manifests, but I wouldn't discount the Holy Spirit. As cockeyed as that may sound at first, may I point out that the brain is a neural wonderland with amazing proofs of intelligent design? For instance, the frontal lobes also exhibit a marked decrease of activity during "praying in tongues," leading to what speakers report as a sense of well-being and spiritual refreshment.
Now since talking about glossolalia in some quarters is akin to turning loose a mouse in a ladies prayer meeting, I need to state I am not than trying stir up religious controversy. I merely want to point to these two phenomena as examples that we are fearfully and wonderfully made.
As writers, especially Christian writers, we do want to remain open to the promptings of the Holy Spirit whether that be through periods of speaking in tongues, through quiet reflection on a favorite Bible verse, or simply dwelling upon the love of God.
I do believe I have experienced moments of heavenly inspiration and I frequently credit the Holy Spirit in helping me do even mundane things, like show me where the car keys went. Likewise, I credit the Holy Spirit for those moments when writing when the story takes a sudden turn in to a rich, undiscovered territory. Those Aha moments should be as satisfying to us as they are humbling, because they say to us that the LORD has taken interest in our writing and wants to steer our work in a direction that will further His Kingdom.