It should work on the fly, but if your tires are worn or inflated unevenly, even a little, it can cause enough binding in the drivetrain to prevent or slow disengagement. If you have a vacuum disconnect front axle, it can also prevent the axle from disengaging even if the transfer case does, and in that case, even though you're in 2WD, you'll see the 4WD light until the axle disengages.
Sometimes it's enough just to put the transmission in neutral and brake lightly. Sometimes you may have to stop and reverse. It depends on how much strain is on the drivetrain, and a little on how healthy your vacuum system is, to unshift the axle.
So before anything else, check your tires.