It sounds like maybe you haven't see our read before you post thread. It has some general suggestions that might help you troubleshoot your problem and get the most out of our support, so please read through that and then see my more specific questions below.
Which motor driver shield are you using? I see your code is for the VNH5019 shield, but you should explicitly include this kind of information in your post. What is your motor, and what is your power supply? Can you please reduce your code and system to the simplest thing that demonstrates the problem. For example, you should be able to remove all of the serial stuff (unless that is causing the problem, in which case you'll be closer to understanding the problem when you start to pare down that part of the code). Can you get the problem to happen without the pot in the system?
Also, please provide a better description of what you are doing, what you expect to happen, and exactly what is happening. Saying "the driver gets locked in either the on or off state" is not all that helpful. (What does locked mean? What input are you providing? What determines if it "locks" on vs "locks" off?)
Finally, please use [ code ][ /code ] tags (without spaces) when posting your code. I have edited your post to add them.