don't execute if kernel is not connected

Avoids weird behavior adding new lines with shift-enter when there is no kernel, or the kernel is not connected.

closes #6958