A Computer Science Researcher discovers AGI by accident and builds a brain that almost kills him. Spends the rest of his sad days, researching scientific articles and journal publications, that hint they are following a similar path that led to the discovery, so he can intervene on time.
Edit: I think it is The Great Automatic Grammatizator written by British author Roald Dahl.
https://en.wikipedia.org/wiki/The_Great_Automatic_Grammatiza...
"... A mechanically-minded man reasons that the rules of grammar are fixed by certain, almost mathematical principles. By exploiting this idea, he is able to create a mammoth machine that can write a prize-winning novel in roughly fifteen minutes. The story ends on a fearful note, as more and more of the world's writers are forced into licensing their names—and all hope of human creativity—to the machine..."
Edit 2: Found it! Had to go back to my 20,000 book library. :-)
It's "Dial F for Frankenstein" by Arthur C. Clarke. A telephone engineer accidentally creates a global AI by connecting telephone systems around the world. The AI becomes sentient and takes control of global communication systems. The protagonist manages to shut down the AI, but the story ends with him remaining vigilant, monitoring the news for any signs that someone else might inadvertently create a similar AI, so he can stop it from happening again.
First published in Playboy; - https://www.isfdb.org/cgi-bin/title.cgi?315611