Fixed crash when the current mouse capture window is destroyed
Fixes https://github.com/libsdl-org/SDL/issues/10494
(cherry picked from commit 91d97a367e9e15bb2067ed0594798dc54c862bb1)
(cherry picked from commit 5ca0639a42c25f3c282b9704da4bf28028ea0ae7)