Is this the first iteration of the Magic Keyboard that takes two double-A batteries? If so, you could turn it off by removing the batteries. If it's the Magic Keyboard 2 with rechargeable batteries, and you've toggled the switch into position so that none of the green shows on the toggle switch and it doesn't turn off, then you'll need to try to manually repair the toggle switch or you'll have to wait for the battery to fully drain. If the toggle switch is broken you may need to open up the device to fix it, which could be difficult on that model and is probably not recommended since the device is relatively cheap to replace. You may be able to get it to turn off by continuing to mess with the toggle switch with the hopes that it eventually works itself into the correct alignment to turn off. Good luck!