fix bug for cleaning global state

'goog is not defined' if some callback is dispatched after cleaning.
Now, clean is performed before next global deps resolve.