Woah. Why go through all that?

Send the WM_CLOSE API call to it and it closes instantly. No need for all that.