Fixed thread getting stuck.