You can detach the keyboard from the tablet while the power is off. You CANNOT detach it if the battery is completely depleted.
So in short, if the Surface Book is 100% turned off, you can hold the "detach" button and the green light will pop up signaling it's ok for it to come apart.