That's a bad thing to happen when the power is up and should be treated as a catastrophic event. As an electronics designer, not many laptops supported "hot plug" on the battery. So all this means is that you need to repair that laptop.