If Trump wins, he'll probably get another term and Cruz might be done for good anyway.
If Trump wins and screws up, Cruz can say "I told you so"
If Trump loses, Cruz can say he always thought of Trump as a bad candidate.

So if Trump does well, it doesn't matter for Cruz. If Trump doesn't, Cruz will benefit. It's a smart game.