On asyncEnd, if done function is defined, get a local var of it

Seems that a race condition exists where the global done var could get
set to null before the function in setTimeout gets executed. In that
case, the d var would get set to null and then would error on `d();`