The pathfinding behavior is very CPU intensive. In your code, you are using a loop inside which you are finding a path. This starts the process of finding a path repeatedly and you will eventually run out of processing power to complete the task so, it is no wonder the game is crashing. Have you read through the documentation and tutorials on pathfinding? If you had, you would see this is not how to use the behavior.
There is a really good tutorial on combining 2 behaviors to get an enemy to chase the player:Read through it. You may find an easy way to do what your are trying to do. Also, make sure to read all the documentation on the pathfinding behavior in the manual and check out a couple other tutorials.
I hope that gets you what you need and good luck with your project.
Thanks for the information. I'm going to do more in-depth research into the pathfinding behaviour. One question, I thought about the processing intensity for the CPU, that's why I added the wait action but it doesn't work, can you shed some light on that?