Action potentials in animal cells are generated by either sodium-gated or calcium-gated ion channels in the plasma membrane. These channels are closed when the membrane potential is near to, or at, the resting potential of the cell. The channels will start to open if the membrane potential increases, allowing sodium or calcium ions to flow into the cell. As more ions enter the cell, the membrane potential continues to rise. The process continues until all of the ion channels are open, causing a rapid increase in the membrane potential that then triggers the decrease in the membrane potential. The depolarizing is caused by the closing of the ion channels that prevent sodium ions from entering the neuron, and they are then actively transported out of the cell. Potassium channels are then activated, and there is an outward flow of potassium ions, returning the electrochemical gradient to the resting potential. After an action potential has occurred, there is a transient negative shift, called the afterhyperpolarization or refractory period, due to additional potassium currents. This is the mechanism that prevents an action potential from traveling back the way it just came.