If we only measure the signal for a short time, the Fourier Transform works as if the data were periodic for all time. If not quite an integral number of cycles fit into the total duration of the measurement, then when the Fourier Transform assumes the signal repeats, the end of one signal segment does not connect smoothly with the beginning of the next  the assumed signal is similar to the actual signal, but has little 'glitches'at regular intervals. The glitches can be reduced by shaping the signal so that its ends match more smoothly. Since we can't assume anything about the signal, we need a way to make any signal's ends connect smoothly to each other when repeated. One way to do this is to multiply the signal by a 'window'function: The easiest way to make sure the ends of a signal match is to force them to be zero at the ends: that way, their value is necessarily the same. Actually, we also want to make sure that the signal is going in the right direction at the ends to match up smoothly. The easiest way to do this is to make sure neither end is going anywhere  that is, the slope of the signal at its ends should also be zero. Put mathematically, a window function has the property that its value and all its derivatives are zero at the ends. Multiplying by a window function (called 'windowing') suppresses glitches and so avoids the broadening of the frequency spectrum caused by the glitches. Windowing can narrow the spectrum and make it closer to what was expected.
