B
考查动词辨析。句意“当她正要去睡觉时,她忽然想起来忘记关天然气了。”It happens that...“碰巧......”;It occurs to sb. that...“某人突然想起......”。故选B。