Fixed issue where not all threads would be ended on disconnect in Core