A synapse can tell which neuron fired first — to the millisecond. When the presynaptic cell spikes a few milliseconds before the postsynaptic one, the synapse strengthens (long-term potentiation); reverse that order and the very same pairing weakens it (long-term depression). This is spike-timing-dependent plasticity.
The referee is one molecule. The NMDA receptor only passes current when two things coincide: glutamate must be bound (the pre-spike) and the membrane must be depolarized enough to expel a Mg²⁺ ion lodged in its pore (the post-spike's back-propagating action potential). Only that coincidence lets Ca²⁺ flood in.
Calcium then decides by amount: a big, sharp Ca²⁺ transient triggers potentiation, a smaller lingering one triggers depression, and a trickle does nothing. Because the bAP arrives while glutamate is bound in pre-before-post but is already gone in post-before-pre, the sign of the change flips as the timing gap crosses zero — learning written in milliseconds.
The simulation stopped unexpectedly — the lesson continues without it. You can move on; nothing you did was wrong.