This may not be 100% reproducible but if you open joy.cpl and go to the XInput page, then the Windows.Gaming.Input page, then click Cancel, the dialog will not close and cannot be closed with either OK or Cancel. The issue is that PSN_KILLACTIVE is sent when navigating away from a page, and then PSN_RESET is sent when the dialog is closed (i.e. OK/Cancel) even if the page is not currently selected. For the sequence above, test_xi_dialog_proc() receives PSN_SETACTIVE, then PSN_KILLACTIVE, then PSN_RESET. On PSN_RESET, since the events and threads have already been closed, execution gets stuck in the MsgWaitForMultipleObjects() loop (so the dialog still works, but there's no way to exit). To fix this, ensure that the PSN_KILLACTIVE/PSN_RESET block only runs if the input thread is running. 9427e8a975199f70a0f029a690e1f622aff6d256 previously fixed this issue for the DInput page, where the UnregisterDeviceNotification() call led to a use-after-free and crash. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10136