Automatic shutdown process

When the battery runs out, the computer fails the automatic shutdown process, as it logs out, but when the computer shuts down, it restarts again. What is the reason?