Tried defining keepRunning as volatile.