Fix the loading indicator not clearing in some cases.