Clear variables on window close

I’m using

DynamicModule[{ var1, var2 },  CreateDialog[ (*some code here*) ]] 

In order to be able to deal with memory isolation for multiple copies of a program running at once. Is there an option to use in CreateDialog to run a command upon the closing of that Dialog? When that window gets closed I would like to clear all the variables to free up the memory.