handle WM_ENDSESSION (fixes issue 2217)