fix bug of not stopping all threads when app exits
in an ugly way