Artificial Intelligence, or AIs, won't just work like any other machine when confronted with a stop button.
Fitness
Most AI's now will have some sort of fitness function, which evaluates how "good" an AI is. This helps to sort out bad AIs in the learning phase of an AI. But in this fitness, the AI has to get to its goal, or it will get sorted out. So the AI will do anything in its power to stop YOU from stopping it.
Solving the problem
There are many approaches to this problem, but a definitive solution hasn't been found yet. One approach is to give the AI as much reward for completing its task and getting stopped by the user. But this approach has other problems connected to it. Now the AI probably won't do what it's told to do. It will try the least troublesome way, which is probably just getting stopped.
Another approach is, that the AI doesn't know about the stop button. But as soon as the AI finds out it will deceive you into thinking it doesn't know. This can work, but there's also a big chance that it won't.
TL;DR
This is a mind-boggling problem. Nobody has found a solution to this problem, yet. I think it's possible, but I'm not an AI programmer. We will see in the future how this plays out and if there will be a solution.
Feel free to discuss and ask questions in the comments, there are no dumb questions! I'll try my best to answer your question and discuss with you. Remember that this is just my opinion on this topic, and this should just be a little reading matter to inspire you to learn more on this topic, and hey, maybe you know more than me and educate me on this matter.