fix a bug: fix a thread deadlock when app exits.