I would keep on flying, and land at the nearest airport with a suitable instrument approach, if still in IMC.
"Electrical failure" normally means alternator failure, which means the battery is no longer being normally charged, but if it has a full charge to start with, might give you ~30 minutes of service at a reduced electrical load.
So the goal is to shed all non-essential loads (e.g. all lights), perhaps even shutting down the master except for brief periodic "peeking".
You want to squawk 7700, and advise ATC of your predicament and intentions (on your handheld radio -- you do have one, right?).
If you have FF, GP or equivalent, you might want to use that to navigate to your nearby emergency destination, perhaps to the IAF, and then turn the master on and use the bare minimum certified panel navs to fly the approach and land.
Obviously you don't want to launch into night IMC (or any IMC) without good flashlight batteries, a tested handheld hooked up (or quickly hookable) to an external antenna and to your headset, and a backup GPS navigator (with its own battery that can last an hour or more) that can find the nearest airport with a suitable IAP and lead you to its IAF.
In a dire pinch, if the electrical system is completely fried, turn the master off and use the backup nav/com equipment mentioned above. If you don't break out into VMC at the IAF, you might have to shoot an emergency approach. Which one and how to do it is up to you and your specific capabilities and situation. (Also consider ASR if the handheld is working reliably.)
Edit: if any gyro is electrical, be ready to ignore it, and if possible put a plug or sticky note on it.
And don't be spooked when you see "no fuel remaining" when the master is off.