Fixed not closing a thread, Fixed metrics related error