You may fall but not hit the ground
Xanathar’s Guide to Everything has two rules about falling on page 77, the first is the Rate of Falling:
The rule for falling assumes that a creature immediately drops the entire distance when it falls. But what if a creature is at a high altitude when it falls?
When you fall from a great height, you instantly descend up to 500 feet. If you're still falling on your next turn, you descend up to 500 feet at the end of that turn. This process continues until the fall ends, either because you hit the ground or the fall is otherwise halted.
Using this optional rule, you could rule that your character starts to fall but, as they have used levitate to halt the fall, you stop falling and will not be falling when you start your next turn. Theoretically, you could fall anywhere from 1 to 500 feet as the rule in XGE states you fall “up to 500 feet” not that “you fall 500 feet or hit the ground, whichever comes first”. I would imagine that the DM would determine how far a character falls each turn, possibly falling a further distance each turn to simulate gaining speed.
There is also a rule specifically about Flying Creatures and Falling:
A flying creature in flight falls if it is knocked prone, if its speed is reduced to 0 feet, or if it otherwise loses the ability to move, unless it can hover or it is being held aloft by magic, such as the fly spell.
Subtract the creature's current flying speed from the distance it fell before calculating falling damage. This rule is helpful to a flier that is knocked prone but is still conscious and has a current flying speed that is greater than 0 feet. The rule is designed to simulate the creature flapping its wings furiously or taking similar measures to slow the velocity of its fall.
According to this section, the “flying creature” (the character) would begin to fall as soon as they were no longer “being held aloft by magic, such as the fly spell”. As they no longer would have a flying speed, due to the spell being cancelled, the last section would not normally apply.
However, as the character casts levitate as they were falling, this would come under “taking similar measures to slow the velocity of its fall“. You would subtract 20 feet from the fall as levitate’s description says you “rise vertically, up to 20 feet”. Theoretically, if you were only 20 feet up in the air when you cancelled fly and cast levitate, you would take no damage.
The last part of the rule for Flying Creatures and Falling focuses on if you combine this rule and the first one for Rate of Falling:
If you use the rule for rate of falling in the previous section, a flying creature descends up to 500 feet on the turn when it falls, just as if that creature starts any of its later turns still falling and is prone, it can halt the fall on its turn by spending half its flying speed to counter the prone condition (as if it were standing up in midair).
What this means is, when you cancel fly, you will start to fall. However, when you cast levitate, you can use 10 feet of movement in order to stop yourself from falling.
So, whilst you would not be able to flawlessly switch to using levitate, it is possible to do so mid air without hitting the ground and taking damage. However, you would always fall at least some distance (even if the DM rules it is only a few feet) so the character would not be at the same height.