Local variables (%this) are deleted at the end of their 'scope'. If you define a local variable inside of a function, it will only exist inside of that instance of running the function.
Global variables ($this) aren't deleted until the simulation ends or a user does so.
Typically, it's considered poor practice to use global variables liberally.