Bluesnooze[1] mostly resolved this issue for me on MacOS. I also own the XM3s, as well as non-Apple Bluetooth earbuds (Edifier X3), neither of which support multiple devices.
>Bluesnooze prevents your sleeping Mac from connecting to Bluetooth accessories.
>Bluesnooze prevents your sleeping Mac from connecting to Bluetooth accessories.
[1] https://github.com/odlp/bluesnooze