How do I know my mac turns off because of overheating?
It would not do that until:

First the fans go at full speed for few minutes. You would hear that.

If that does not keep the temperature from climbing, it would cut down the CPU power. You would feel that in computer becoming sluggish (slow).

Normally the above is sufficient to prevent overheating.

If all that has failed it would not just shut down, it will try to shut down correctly.

Look in the Console for kernel[0]: Previous Shutdown Cause: ?

You could look in to Activity Monitor to see what is happening while under stress.

There is also a app called Istat that displays lots of parameters.