Fix correct termination of HeavySort