When you're swimming parallel and not moving further away from the beach, you're no longer being ripped away from the beach.
You can feel it easily if you can touch or swim down to the bottom. Also, it's often possible to see where the sand bars and reefs that are next to the rip are located either by seeing the color of the ocean floor or by seeing the waves breaking; get behind those and you'll be out of the rip.