Wrap calls to setgenerate...

...and drop unnecessary rpc call to getblockcount, since every simulation
starts over.
handle panic and try to cleanup