Self-healing short-circuits in organic light-emitting diodes and solar cells