Ensure that threads are stopped when changing generations