What I remember: I'm pretty sure it was in an asimov short story collection A group of SF writers are discussing ideas/stories/characters something, one tells a story about a man who is struck by lightning/electrocuted and becomes trapped in his story. The payoff is that the man telling the story is stuck in his story (implication is that all the people in the conversation are also part of his story)
"Exile", a short story by Edmond Hamilton, also the answer to this question; first published in Super Science Stories, May 1943, available at the Internet Archive. You might have read it in the paperback anthology The Great Science Fiction Stories Volume 5, 1943 or the hardcover Isaac Asimov Presents The Golden Years of Science Fiction: Third Series, both edited by Isaac Asimov and Martin H. Greenberg.
Four science fiction writers are talking after dinner about creating worlds. One of them, Carrick, tells about a barbarous world he created that came into existence due to his proximity to a power plant. He imagined himself in this world and was transported there—Earth. Now, he supports himself with his old trade, writing science fiction.
There is no electrocution or lightning strike in the story; the transition is caused in some unexplained way by a nearby power plant:
"I tried to reason the thing out so that I could dismiss that crazy conviction. If my imagining a world and universe had actually created them, where were they? Certainly not in my own cosmos. It couldn't hold two universes—each completely different from the other.
"But maybe that world and universe of my imagining had crystallized to reality in another and empty cosmos? A cosmos lying in a different dimension from my own? One which had contained only free atoms, formless matter that had not taken on shape until my concentrated thought had somehow stirred it into the forms I dreamed?
"I reasoned along like that, in the queer, dreamlike way in which you apply the rules of logic to impossibilities. How did it come that my imaginings had never crystallized into reality before, but had only just begun to do so? Well, there was a plausible explanation for that. It was the big power station nearby. Some unfathomable freak of energy radiated from it was focusing my concentrated imaginings, as superamplifled force, upon an empty cosmos where they stirred formless matter into the shapes I dreamed.
We chuckled. But Carrick was deadly serious.
Madison humored him to the end. "And how did you finally get back home from that other world you'd created?"
I never did get back home," Carrick said with a heavy sigh.
"Oh, come now," Madison protested lightly. "It's obvious that you got back some time."
Carrick shook his head somberly as he rose to leave.
"No, I never got back home," he said soberly. "I’'m still here."