The variable is persisted once the process stops "flowing", this is when the transaction is comitted. The process stops "flowing" once a wait-state is reached or the process is ended.
In case the variable was set somewhere right before the process was ended (withour waitstate in between) the variable will only exist in history table, not in runtime variable table.