Add a mutex on the stop condition of the render loop.