As for the batsman changing his mind and walking back to the wicket, this is a grey area. Law 27 provides as follows:
"1. Umpire not to give batsman out without an appeal
Neither umpire shall give a batsman out, even though he may be out under the Laws, unless appealed to by the fielding side. This shall not debar a batsman who is out under any of the Laws from leaving his wicket without an appeal having been made. Note, however, the provisions of 7 below.
2. Batsman dismissed
A batsman is dismissed if
either
(a) he is given out by an umpire, on appeal
or
(b) he is out under any of the Laws and leaves his wicket as in 1 above.
...
7. Batsman leaving his wicket under a misapprehension
An umpire shall intervene if satisfied that a batsman, not having been given out, has left his wicket under a misapprehension that he is out. The umpire intervening shall call and signal Dead ball to prevent any further action by the fielding side and shall recall the batsman.
...
9. Umpire's decision
An umpire may alter his decision provided that such alteration is made promptly. This apart, an umpire's decision, once made, is final."
Well 27.9 probably has no relevance because Amla apparently wasn't given out.
Therefore if he was out it was because he left his wicket believing he was out (27.1 and 27.7).
Looking at 27.7 it's arguable that his change of mind about "walking" was legitimate - he was under a misapprehension that he was out.
Was he too late to decide not to "walk"? The Laws don't say (so far as I can see) that there's any set time after which it's too late for Law 27.7 to take effect, and if he's not left the field and the new batsman has not entered the field then I can't see that Amla could have lost his right to seek to resume under 27.7.