If storing a laptop/portable Mac you should always remove the battery. Batteries should be fully charged (if functional) to ensure their design capacity doesn’t degrade over time. Older batteries such as Ni-MH (Nickel–metal hydride) can leak and corrode components and should always be removed. This can still occur for older batteries even when removed if the original battery cells haven’t been refurbished.
Li-ion (Lithium-ion) batteries do not leak but should be removed anyway to preserve their design capacity and shelf-life. When storing Li-ion batteries they should be charged to ~80%, and recharged back to 80% when they reach 20-30% capacity. Poor quality Li-ion batteries can swell over time and become incredibly unstable. As soon as you notice a battery bulging you should stop using it and store it outside until you can safely dispose of it. Li-ion batteries can burst into flames if pierced or damaged.
The image below is a PowerBook 1400 battery in the early stages of leaking. The battery acid had begun to corrode the components inside and would have made it’s way to the PowerBook’s internal components if left any longer.
Clock batteries should always be either removed or replaced. They leak onto the logic board over time and destroy the computer. If you’re not using a desktop computer for an extended period of time, always remove the battery.