Time duration of a signal to determine the peak frequency
What window function are you using when you apply your FFT?

If the signal being analyzed is simply truncated on both ends, the window is rectangular.  

Lets call the length of time that you generate your signal the analysis window and call the signal you create the "windowed signal".  In this case I'm assuming the window to be rectangular.

One interpretation of the math behind the FFT is that the signal being analyzed is periodic and the complete version of the signal is formed by taking the unaltered input from the analysis window and placing it end to end so it repeats indefinitely as illustrated below

....| Windowed Signal (-1) |  Windowed Signal (0) | Windowed Signal (+1) |...

Depending on where you stop your signal generation, you may introduce discontinuities in the periodic signal that the FFT assumes when you do your analysis.  For example if your signal generation stops at the peak of a sine wave but starts at a 0 crossing, the signal at the point where one windowed signal segment meets the nest will abruptly go from Vpeak to 0.  This discontinuity introduces spurious frequency content in the FFT.  Also if you don't make your analysis window an integer multiple of the period of signal being analyzed, the FFT will assume the signal is periodic in a different period than the signal being analyzed (actually the period assumed by the FFT is always the window length).  this will create frequency lobes that are not harmonically related to the signal you are testing.

As you increase the length of your window, the contribution of the discontinuity and window period diminish, so the longer duration signal will give more accurate results.

The way to improve accuracy of the FFT frequency and/or amplitude resolution is with the use of non-rectangular window functions.  There are a bunch of window functions that are designed for this purpose.  The window function is multiplied by your time domain data (signal).  The effect of the window function is to taper off the amplitude of at the ends of your analysis window (the start and end of the signal you generate) so the edge effects are reduced in the FFT computations.  Different windows have different advantages in frequency or amplitude resolution, so there are trade offs in choosing a window function.

In general, if you want decent resolution in your FFT, you should provide a data length that is least 2x the period of the lowest frequency to be represented and apply a window function to soften the effects of signal truncation.  Note that the longer you make your time window, the greater the frequency resolution of your FFT.  The bins are spaced at 1/T and its multiples where T is the duration of your signal.

There is plenty of information on the internet that discusses the different window functions  used in FFT analysis.  Just Google "FFT window functions".