I have a python-based GTK application that loads several modules. It is run from the (linux) terminal like so:
./myscript.py --some-flag setting
I know this solution isn't technically what you are asking for but if you want to be 100% sure you freed everything or don't want to rely on dependencies you could just run the script in from a loop in another:
import os, time
while 1:
os.system("python main.py")
print "Restarting..."
time.sleep(0.2) # 200ms to CTR+C twice
Then you can restart main.py as simply as:
quit()