Cleaned up thread destruction code a bit

It was overcomplicated because old code that has long since been replaced.
Cleaned up some more thread destruction.

The client now tells its delegates it has stopped, so they can take appropriate action. The meant i could move the actual connection close synchronisation to the server to take place within the client. This in turn enabled me to remove a synchronisation thread in the gui that was solely there to wait until the client server synchronisation was done.