Returns a pointer to the task.
If we are not in an action or action end handler, then returns nullptr.