Why would he do that? Because he wants to win or to have leverage for possible VP spot.
Same with Kasich and Rubio. Why would they stay in if they wanted to elect Cruz?
I am sure Cruz will get something out of the deal(probably not VP) especially if he is successful in blocking Trump but that doesn’t change the fact that Cruz will be a tool of GOPe. You know the GOPe, Democrats, media, left hate groups, foreign countries all want to stop Trump. That’s the goal and he will be despised so despised forever if he throws the nomination onto the floor for the Romneys, Bushes, and Clintons to rape this country.