When the PG knows the call has ended it tells the router which then instructs the logger to write the Termination Call Detail record. It saves all the values of peripheral variables in the record. You can see the TCDs in the HDS database once they are replicated to the HDS.
I have another question; do peripheral variables pertain to each script or all together; for instance, can you set a peripheral variable (1) on one script and have that script go to another script, and set peripheral variable (1) to a totally different value on that script? Or can Peripheral Variable (1) only have one value globally?