Electroweak fermion number violation and the production of stable particles in the early universe