shell: only check for active shell when closing if it is set

Solves the bug:

shell foo
shell bar
shell foo
close_shell foo
close_shell bar