Read a book or short story a dozen or more years ago, from Dublin Public library, in Dublin Ohio. It was a mystery, set in not distant future, in which at the end (near last pages or paragraphs) the main character discovers that he is a character in a video game or computer simulation.