Slow slope power-on/Power off PSU behaviour.

You want to test the BOR, PD bits at the start of the program then.

Check the datasheet for STATUS, PCON register