I thought the

[pascal]Msg.Result := -1; [/pascal]

should actually be

[pascal]Msg.Result := 0;[/pascal]

meaning handled, therefore it won't power off. Have you tried changing the result to zero?