There are certain talks (messages) between the Os and your application while OS try to shut down...
OS actually sent a WM_QUERYENDSESSION to your application, but as you didn't handled it it got a false response, marking your application as blocking...
Read this paper, to see how prepare your application to properly play during shut down process:
Guidelines for Applications (Windows)[
^]