No time to post an example right now but, I believe you can use the PostMessage API, passing WM_CLOSE (&H10) for the wMsg parameter. Use EnumWindows along with a callback function that uses GetWindowTextLength and GetWindowText to identify and acquire a handle for the appropriate window.
There may be a better (safer) way to identify the correct window but I don't know what it is.