Will now terminate correctly