diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index b19603e8ce..bd5770640c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -28,7 +28,15 @@ struct ppu_thread_cleaner { if (u32 id = old_id.exchange(new_id)) [[likely]] { - if (!idm::remove>(id)) [[unlikely]] + auto ppu = idm::get>(id); + + if (ppu) + { + // Join thread + (*ppu)(); + } + + if (!ppu || !idm::remove_verify>(id, std::move(ppu))) [[unlikely]] { sys_ppu_thread.fatal("Failed to remove detached thread 0x%x", id); }