Fix a possible error on completion
Improve behavior of completion canceling (close #206)