Running code when a script exits

Just throwing out a random idea, but is it different if you execute the script with mix run?