Variables are the way to go. Just set one to 1 after terminal is done with its work and put a condition that tells to skip the code if variable is set to 1.