provide a 'back' or 'cancel' or 'close' button to return to whatever page that particular template was accessed from I have two templates. For the purpose of this question lets say the first template is step 1, and the second is step 2.
There are links to launch these templates all over the site, but some times an entry is defined and sometimes its not. if the entry is defined, step 1 is skipped.
On both steps I have a 'close/cancel' button. I need these buttons to go to whatever url the user was on when they 'launched' this process.

Is there a way of storing a URL as a variable when the 'launch' button is clicked even after moving from step 1 to step 2?

see user journey diagram:
You could use the Cookies plugin to store the last visited URL before the user hits one of the "step" templates, i.e. by putting something like the following in every template where the links to the "steps" template occurs:

{{ setCookie( 'lastUrlBeforeStepStuff', craft.request.url) }}


Then, inside your "step" templates, you could render the "cancel" links like this:

&lt;a href="{{ getCookie( 'lastUrlBeforeStepStuff' )|default('/some/path/to/fall/back/to') }}"&gt;Cancel&lt;/a&gt;