When the battery is connected, it acts as a voltage buffer, helping to regulate the electrical system's voltage. Disconnecting the battery while the engine is running essentially removes this buffer and can cause voltage spikes as the alternator tries to adjust to the sudden change in load.
However, if you disconnect the battery post with the engine off, there is no power flowing through the electrical system, and therefore no risk of damage from voltage spikes.
It is generally safe to remove the battery posts when servicing your vehicle or performing electrical repairs, as long as you take the proper precautions, such as disconnecting the battery before starting any work.