XD-1783: Make failed deployment cleanup more robust

Handling some edge conditions for failed module deployment cleanup.