Why does a pendulum eventually stop swinging?