Islander is correct - the idea is that the fore stalls before the main, which continues to supply drive closer to wind and at the same time gives the stern a sideways push. By the time that the main stalls, there should be enough inertia to carry the bow across the wind, after which the boat falls away and allows the sails to refill and drive off on the opposite tack.
Either too much sail for the conditions or a badly balanced rig can both overcome any steering that the rudder applies. Trying to turn into a wave at the wrong time (i.e. the wave hits when you are hoping that the inertia will carry the bow across the wind) can result in the boat being slapped back.