There is a fun story based off this idea, A Short Stay in Hell by Steven Peck [0]. In the story the character dies and wakes up in a kind of hell that is basically a version of the library of Babel. There are other people there. You're allowed to leave if you can find the book that has your life story in it.
[0] https://www.amazon.com/Short-Stay-Hell-Steven-Peck/dp/098374...