Win95 shutdown discards msgdlg

I have a message to display(with ok confirmation) whenever a program shuts.
It works ok when programs shuts using alt-F4 or any other way, but when
program shuts while win95 shutdown this message is not shown or show on the
fly without waiting for confirmation, Why ?