fix when template expansion is cancelled