The code will depend on how you have everything connected in your system. Do you have code that moves your motors right now? In general, you would add some logic to your code that checks the encoder readings periodically and turns the motor drivers off when the desired values are reached. A more advanced control mechanism would be a PID algorithm that checks the encoder values and slows the motors as the encoders approach the desired values. If you search, you should be able to find a number of code examples for the Arduino that use PID.
If you post your existing code here and diagrams or pictures that show how everything is connected, I might be able to offer more specific advice.