I'm not going to spend a lot of time going over this because it's straightforward and not terribly important.
临时 to mean 'at the last moment' can only be used in this way:
It has to emphasize a change, something that happens from what 临时 is describing that causes something to change of plan. This is a little weird, so let's look at 及时。
Ok, so there's a change here, but the plan is saved, rather than scrapped. It's more like ‘in the nick of time'. 临时 doesn't have that meaning (ever, I think. Like if you want the plans to be canceled I don't think you use 临时, I would use 及时。）
Obviously 临时 and 及时 have other uses, but you should know them and we aren't going to talk about them here.