Wrote (almost all of) exit()