UPDATE
I also tried several other options like moving the code which checks UserPermissions to OnSuccess method, Using Promises with the JavaScript Client Object Model etc. Here is a pictorial representation of what happens when I execute the code. The ECB menu is already generated by the time the code in OnSuccess method is executed.