John pulled their support when (actually probably because) they were winning.
And after that Castro took over the whole shooting match thanks to his good friend in the white house.
I can remember my father announcing the Bay of Pigs invasion at dinner when it happened. I think Kennedy thought he could conceal the US involvement if he called off the promised air support.