If you want to grab a specific number of samples, you can add the gr.head block.
You should use fg.run() not fg.start() followed by fg.stop(). Also be sure that head is upstream of all
of your sinks (if you're using more than one). head effectively returns "EOF" after it has processed nsamples.
Soon I will put an example here for the same :)