You have several ways to do this.
1) You could use a template including a fix joint when certain distance is achieved (the computation of the system can be done using a sensor)
2) You can add contact between the bodies as it happens in the real life I guess.
3) You could add a second force with a impact function to limit the movement (analog to use contacts)
4) You could include a bistop function on the joint providing a range that the joint can translate.