Fix a potential crash when removing software