You could count your gosub nesting level in another variable.
Increment for every gosub, and decrement for every return.
You don’t know about PBP's own gosubs, but they are supposed to be the compiler’s problem, and aren’t your responsibility.

So you would know if the value wasn’t zero when you thought it should be.