This sounds like the classic "I Have No Mouth, and I Must Scream" by Harlan Ellison.
The story takes place 109 years after the complete destruction of human civilization. The Cold War had escalated into a world war, fought mainly between China, Russia, and the United States. As the war progressed, the three warring nations each created a super-computer (with AI) capable of running the war more efficiently than humans.
The survivors live together underground in an endless complex, the only habitable place left. The master computer harbors an immeasurable hatred for the group and spends every available moment torturing them. AM has not only managed to keep the humans from taking their own lives, but has made them virtually immortal.
Plot summary (Contains spoilers for the entire plot)
Ted, in a moment of clarity, realizes their only escape is through death. He seizes a stalactite made of ice and kills Benny and Gorrister. Ellen realizes what Ted is doing, and kills Nimdok, before being herself killed by Ted. Ted runs out of time before he can kill himself, and is stopped by AM. AM, unable to return Ted's four companions to life, focuses all its rage on Ted. To ensure that Ted can never kill himself, AM transforms him into a helpless, gelatinous blob that is incapable of causing itself harm, and constantly alters his perception of time to deepen his anguish. Ted is, however, grateful that he was able to save the others from further torture. Ted's closing thoughts end with the sentence that gives the story its title. "I have no mouth. And I must scream."