There’s a scifi short story about astronauts where things stop existing if the astronauts can no longer interact with or they no longer think about an item. It ends with a single astronaut who ends up floating in space by himself.
Thanks to @Dragan Milosevic
I think that is the short story I was thinking of, Ray Bradbury's "No Particular Night or Morning"
Hitchcock and Clemens are part of a rocket's crew, traveling through outer space. Hitchcock remarks that he doesn't believe in Earth anymore, but Clemens disagrees, saying he dreamed about it this morning. Hitchcock says there isn't any morning, because it is always night. As they both look out the observation window into space, he goes on to say that he doesn't believe in anything he can't see or touch. Clemens explains that he knows Earth exists because he remembers it, and he tells Hitchcock, "You've got no imagination, Hitchcock old man. You've got to learn to hold on."
At lunch, Hitchcock says stars aren't real, either, because they're too far away. He also says he's always thought of the past as a series of deaths: you die at the end of each day. Suddenly he gets up and leaves. The others at lunch express concern that Hitchcock might be going insane. Clemens goes to find Hitchcock, who says he wants a way to have proof at all times that things not in his sight are real. Clemens tells him that's not how it works. Hitchcock explains it was his sense that there are gaps between actions and the memory of the actions that made him want to travel in space. In space, he says, he could be "away from all the somethings with gaps in them that couldn't prove themselves."
Hitchcock continues to deteriorate. The psychiatrist is called in to help, to no avail. Eventually Hitchcock puts on a space suit, opens the airlock, and walks out. Through the helmet the crew hear him babbling to himself, "No more space ship now. Never was any. No people. ..."