Task is activated with ActivateAbility Blueprint node.
Ideally the context is valid, yet for some reason when you hit ESC while an ability is playing you will get a crash because context is messed up. The same would happen with your built-in abilities, but I can see your code clearly adds a Context.IsValid() check inside OnTaskEnd()