fixes leak of GenericThread and also fixes crash in octree servers on client disconnect

this fixes #1549