My Canon Powershot SX40 stops recording regularly and predictably.
The squares in a row on the right represent the buffer memory of your camera.
When you are recording video the data goes roughly as follows:

Sensor -&gt; Buffer memory -&gt; Memory card  

When the last square turns red it means the buffer is full. This is caused by the fact that the buffer memory could not move it's contents to the memory card fast enough. A faster memory card would allow the buffer to load it's contents in time and you shouldn't see the red square anymore.

Baseline is: get a faster memory card.