This is a grievous thing to say aloud, much less think, but I wish that the suicide of Robin Williams made less sense to me than it somehow does. I say that with very little real knowledge of the man, his inner being, or the whole of his life. I encountered him only once, twenty years ago, but the memory is distinct. I found Mr. Williams good-hearted, hilarious, talented, and remarkably, indescribably sad.

We were in the Maryland morgue on the given day, though the location had little to do with the sadness. Mr. Williams was guesting on an episode of NBC’s Homicide: Life on the Street I had cowritten with my college-newspaper comrade, David Mills. It was the first attempt at a television script for either of us, and until Mr. Williams had agreed to sign on as a guest star, our effort had seemed something of a miserable failure.

For one thing, we had originally written the episode for season one of the network drama. But NBC execs, reading a narrative in which a mother of two is shot to death in front of her husband and children and no warm victories follow thereafter, thought the effort too grim. Executive producers Tom Fontana and Barry Levinson pulled the script from that first season’s order of nine episodes, subbing another in its place.

So much for a career in television, we had assumed. Mr. Mills went back to the Washington Post; I remained on the metro desk at the Baltimore Sun. But after Mr. Fontana had somehow managed a paltry four-episode renewal of the show for a second season, the script was resurrected. Mr. Williams, who had been directed by Mr. Levinson in the earlier triumph of Good Morning, Vietnam, had agreed to take the role of the husband.

This was a big deal. It came at a time before premium cable, and before film stars would be caught dead guesting on network television shows. Moreover, the role called for a dry, humorless tour through post-traumatic stress, guilt and unbridled grief. It was not a Robin Williams role, to be sure. But he was box office and if he was willing to go dark then NBC was willing to go dark as well, at least for one hour. And so, many months after we had turned our script in to Mr. Fontana, David and I were told that it would be filmed after all. Or at least half of our script would be.

The arrival of Mr. Williams required some rewriting — given that we had divided the scenes equally between the stricken family and the three young men complicit in the robbery-murder. One does not acquire Robin Williams in order to have him off-screen in every other scene, and so, Tom and Jim Yoshimura set to work writing additional pyrotechnics for the guest actor and trimming back on the intricacies of the relationship between the three suspects. By the time they finished, a little over half the pages of our original script were still in evidence.

In the communal world of dramatic television, getting half your pages through editing is, I now know, a victory for any freelance writer. But at the time, coming from newspapers, so much rewriting constituted abject failure, if not incompetence. In reading the finished script, I felt embarrassed and unworthy.

What I couldn’t know then was that the entire enterprise was hanging by a thread, that NBC had effectively cancelled Homicide after the low-rated first season, that Tom had talked Don Ohlmeyer into the four-ep renewal over drinks and begging, and that Barry and his partner at the time, Mark Johnson, had secured Mr. Williams as a last-ditch stunt-cast to save the show. Never mind my affections for Scene Two, in which the three corner boys discuss Chicken McNuggets and the corporate co-opting of individuality (yeah, that’s where that schtick came from), the mission here was to have the leading comic actor of his generation carry us up to the mountaintop with a thirty share.

So when producer Gail Mutrux invited me to set to meet Mr. Williams, I was actually torn. David and I both felt that we had failed to deliver a complete script suitable for shooting, but more than that, I was ill at ease with this strange stepchild that had arrived in my city. Based on my non-fiction book, but effectively its own universe, the NBC show was something that I could admire, but not yet accept on its own terms. I didn’t understand a film set. Or actors. Or process.

Even before my edited script was fully published, I had gone on my lunch hour to set during the previous episode. I suppose I wanted a victory lap for even having my name on a television script, even if half of it had been rewritten. Kyle Secor came up to me first, asking if he would have scenes with Robin Williams.

“No, not that I wrote. You’re not really big in the ep. It’s mostly Melissa and Danny.”

Richard Belzer made the same inquiry.

“Not much. Maybe a line or two.”

That night, the phone rang in my South Baltimore rowhouse. It was Tom Fontana, calling from New York. He had some advice for me. At this late vantage, it is, I will attest, good advice by and large.

“You talked to the actors.”

“Ummm…”

“Never talk to actors. Never, never, never, never talk to actors.”

He proceeded to explain to me how any actor who was unable to share a scene with Mr. Williams would be in open rebellion against the production and that I had revealed myself, in the most off-handed way, to be a babbling idiot. Do not, he said, talk to the actors about anything, ever again. Click.

So, yes, the invitation to return to the film set and meet Mr. Williams during the ensuing episode had me at odds with myself. On the one hand, I had the ire of Tom Fontana ringing in my ear. On the other hand, I was a crime reporter in Baltimore and Robin Williams was a mighty cultural icon, a singular talent of a kind that someone of my station might encounter once or twice in a lifetime. And yet, again to the first hand, I was still ashamed of having failed to deliver a full script; some of Mr. Williams’ most notable scenes were at the pen of others more talented.

In the end, I went; I couldn’t help it. I dumped my worn LP of “Reality…What A Concept” in the back seat of my car and drove to the Office of the Chief Medical Examiner, palms sweaty, trying to think of something, anything, clever to say to one of the planet’s fastest and most comic minds.

Except when I got there, everyone warned me that Mr. Williams was not in that frame of mind. The crazed, manic stand-up routines, the machine-gun witticisms and impersonations — all of it was on hold as he tried to live in the shattered soul of a husband and father who had just lost his wife to sudden, implacable violence. He was, I found, the most in-character actor on that film set.

So there I stood, a putz with a dog-eared comedy album under my arm, waiting my turn for god knows what, as Mr. Williams sat in a small conference room, alone and ignored, while the crew set up lights and turned the camera around for another shot. When Lt. Gary D’Addario, one of the original Baltimore detectives in my book and then a tech advisor on the show, finally screwed up enough courage to disturb the man, I watched, stricken, as the lieutenant produced the same comedy record for an autograph. Shit, no. I went back to my car and dumped the LP. Never go civilian, I chastised myself.

Instead, I watched them film a scene, half-written by David and myself, then wandered over to craft services to liberate some Fig Newtons and a bottled water. And there, to my surprise, was Robin Williams, prowling the table, still seemingly wearing his character’s pain. I swallowed and offered my hand.

“Mr. Williams? I’m David Simon. I wrote the script, or some of it anyway. Thank you for everything you are bringing to the performance.”

He smiled, thanked me in return for the work, and asked if I had been writing for Barry and Tom for long. No, I explained, it was my first scriptwork and in reality, I was a newspaper reporter here in Baltimore. In fact, I needed to get back to the office before too long. He showed some mild surprise, and then we stood there, without much else to say. I wanted to offer something — anything — and I thought about the Penn Street morgue in which we were standing.

“Have you ever heard of the Nutshell Studies?”

He had not, of course.

“They’re upstairs, off the hallway up there. I can show you. It’s not anything you could imagine, and since we’re actually in the morgue today…”

He nodded, a bit wearily, I thought, and a nervous production assistant followed us upstairs as I tried to explain the dollhouse-sized dioramas that were on display at the Office of the Chief Medical Examiner here in Baltimore. Created as part of the Francis Glessner Lee Seminar for death investigation, a training regimen for police detectives originally funded by Harvard University, each diorama featured the occupants of a dollhouse room in the aftermath of violent death. The scenes were carefully detailed, and a detective in the seminar, as part of his final exam, could stare down at a tableau and determine, from the evidence in each room, whether the doll in question had died accidentally, taken his or her own life, or been willfully murdered.

Mr. Williams looked at each of the rooms, asking questions, fascinated by the macabre display. He guessed at a seemingly accidental death that was in fact a murder, then guessed again at a kitchen suicide by a young girl that seemed at first glance to be a stabbing. I could offer solutions to most of the displays only because I’d learned the answers, years before. The actor took it all in, clicking the buttons to light each diorama and then staring at all of the morbid goings-on until the P.A. told him he was needed back on set.

“How long has that been here?” he asked as we walked back.

“They’re from the 1940s, I think.”

He nodded solemnly. Not a joke to be had. I tried to prompt him:

“Dollhouse from Hell.”

He smiled for just a moment, but followed the P.A. back downstairs to the set, where the grips and gaffer were still lighting. And then, suddenly, it happened. Nothing specifically to do with the dollhouse horror show, or even the fact that we were filming in a working morgue, but instead the arrival of Mr. Levinson, the executive producer, set him off. I wish I could remember the sequence, but there is no way in hell:

It began, I think, with something about Barry arriving as a mohel to circumcise the cast and crew, replete with an imitation offered up with Hasidic accent, then lurched into a string of jokes about how reluctant crew members could opt for an antemortem autopsy downstairs if they didn’t want to be so fixed by Mr. Levinson. There was a segue into all the other morbid Baltimore locales that would be featured in the episode, and all of the ghoulish degradations that would be endured by the crew, following by some savagery about the film caterer and then some banter with Mr. Belzer, who tried to hang for a few bon mots. But no, Robin Williams was firing all rockets, leaving earth’s orbit. I can’t remember all of the sparks of comic synapse, the absurd connections, the twisting journey from one punchline to the next. I have a specific recollection of him announcing Mr. Levinson’s new NBC drama as “The Pope and Judy,” a warm-hearted romp that would make everyone forget that depressing mess about murders in Baltimore: “He’s the supreme pontiff of the Roman Catholic Church; she’s an adorable puppet.”

And then a mock-Italian voice, as a pope tries to fellate a falsetto-voiced puppet — the comedian’s left hand — with a communion wafer.

You had to be there. And, yes, I know that the phrase is used to connote moments that are less humorous in retrospect, but with Mr. Williams the live-wire volatility, the no-net comic gymnastics was part of the allure. If you were there, and I was, then you could scarcely breathe from laughing so hard and so long. The crew stopped working, forming a semicircle around him. Word went down the hallway and out to the trucks. More people rushed in to catch the shooting sparks, so that the entire production came to a halt as Robin Williams, quiet for days in the role of a grieving, wounded man, finally exploded. He was soaring for at least another five minutes before Mr. Levinson gave the slightest nod to his watch: We were losing the day.

Mr. Williams caught the look from the producer and ended the impromptu routine abruptly, with an awkward smile. His breathing was labored, and he looked to be genuinely embarrassed by his demonstration as cast and crew applauded with warm delight before returning to work. But it seemed that the actor had gone there as much for his own needs as for the audience, that he had come back downstairs from the dollhouse of the dead, readied himself to shoot another painful scene of grief and guilt, and then, in manic desperation, reached out for as much human comedy as ten minutes will allow.

I last saw him in the hallway, using the few remaining minutes before filming to face the wall and reacquaint himself with whatever horror he was trying to channel. He was sweating, too, as if it had taken all he had to rise to that warm summit and provoke such laughter. To my great surprise, his face was that of an unhappy man, and I retreated, saddened and surprised by the thought.

His performance in that Homicide episode was brilliant and thorough, and when broadcast, the ratings assured that the NBC drama would run another five years. Yesterday, after the news broke, Jim Yoshimura wrote to me his sadness and reflected on the fact that he would be a starving playwright now or worse if not for Robin Williams. Me, I’d be on a newspaper copy desk somewhere. David Mills, too, would have departed this vale as something other than a dramatist. All of our lives turned because a very rare and talented man came to Baltimore for a week and a half to film a television episode.

I know it’s of little moment compared to his greater achievements, and it matters not at all now to his friends and family, to those who knew and loved Robin Williams and held him close. But I for one am deeply grateful, and today, despite myself, I can’t help but think of that last, hard moment, alone, in the morgue hallway.