Fixed bug where joining the last thread would give issues under certain circumstances.