Setting the process priority to something lower than normal would be the thing to do.

Ideally, you want your program to have as much CPU as possible when there is absolutely nothing else to do.

But if there is something more important, like any of your normal apps, then the OS should stop running your background program and run your normal programs.