Prevent segmentation violation upon exiting

If primecoind is generating coins at the time of 'primecoind stop',
it can/will segfault:

Core was generated by `./primecoind'.
Program terminated with signal 11, Segmentation fault.
    (this=0x7f3a64000d20) at prime.cpp:552
552	        unsigned int nPrime = vPrimes[nPrimeSeq];

This occurs because in thread number 2, exit() gets called,
which in turns calls atexit() / on_exit() handlers. Boost registers
some handlers to free memory (OpenSSL specifically which causes the
above to result in segfaulting.)

So the fix is to stop the thread group in GenerateCoins() by telling
it to not generate coins, which results in a clean process exit.

The above crash can be reproduced by running primecoind in coin
generation mode, and stopping it with 'primecoind stop' under
Ubuntu 13.04, latest apt-get update / apt-get upgrade -y.

(Tips welcome, ARhURiSGy9NMiXQr2Q9h3AL8qPntcsSKkF - it will make up
for the orphans I'm seeing :-( )
Modify shutdown thread some more

The boost equivilent of pthread_cond_signal would be better than
spinning in a loop, but I don't know enough about boost to
implement that :>
Merge pull request #4 from thared/master

Graceful shutdown of miner threads (David L. Unger)