correctly shutdown texttospeech and more elegant socket close