Using WhenEvent in ParametricNDSolveValue

I want to solve an ODE and find the time the function y(t) vanishes.

ClearAll[Evaluate[Context[] <> "*"]]
ClearAll["Global*"]
K[t_, s_] = 1 + 0.001 Sin[t] + 0.001 s;
p := ParametricNDSolveValue[{y''[t] +K[t, a Sin[b] y[t]] y[t] == 0,y'[0] ==a Cos[b] K[0,a Sin[b]],y[0] == 1, WhenEvent[y[t] == 0, {Clear[qprime], qprime = t, "StopIntegration"}]}, {y[qprime], qprime}, {t, 0, 10}, {a, b}]


When I call p, I get the vanishing time

p[-1, 1]
{-2.60209*10^-17, 1.07591}


But when I use a Table and call p with different parameters a and b, I don't get the correct result:

Table[Evaluate@p[e, 0], {e, -0.5, 1, 0.5}]
{{-0.212856, 2.35522}, {-0.70736, 2.35522}, {-0.352916,2.35522}, {-1.11022*10^-16, 2.35522}}


The result is wrong, as a tuple represents {y(t),t}, where t is the time I stopped the integration. Moreover, the time the integration stopped, is the same although the ODE is different as I changed the parameters. Thanks in advance

• MMA version 13.1 Windows 10: I get from Table: {{-6.93889*10^-17, 1.10705}, {9.02056*10^-17, 1.57046}, {-1.38778*10^-16, 2.03375}, {-2.77556*10^-17, 2.35522}} Oct 14, 2022 at 16:19

Change definition of p:=...to p=...
p = ParametricNDSolveValue[{y''[t] + K[t, a Sin[b] y[t]] y[t] == 0,
`