*.sh/cleanup(): store $? locally

avoids inspecting the wrong value if checked after other operations,
e.g., cd.

Change-Id: Idecbbe4c9a551021f9dddcdbc69936ddda9175b5