kill thread only when it exists