Fix crashbug when shell is removed twice.