Sometimes ya kinda get backed into a corner. I usually try to find a spot while I still have some time left, but it doesn't always work out that way. Fortunately I play it on the conservative side, so I've rarely gotten caught out.
Once, though, I was driving (OTR TT) through TN, looking for a place to park for the night. Three exits, several truckstops, no parking at all. Even the spaces you weren't supposed to use were crammed with trucks.
Finally, I noticed a line of trucks parked on a really wide ramp shoulder, and I pulled over. No time left, and my eyelids were in open rebellion, so I went to sleep.
Four hours later, there's a knock on my sleeper. I clamber up front to see that all the other trucks have gone, and two state troopers grinning at me from beside the truck, ticket book out.
I wasn't aware of it when I pulled over, but one of the other trucks had been between me and the "no parking on ramp" sign.
Sometimes, you get caught between a rock and a cop. "Good" news was, folks were pulling out of the truck stops and I was able to finish up my sleeper time, though technically the trooper who'd just chased me off could easily have written me up for driving over hours to get to the lot.