How to make the console frontend to automatically disconnect from a terminated kernel

When the main kernel is terminated (e.g. because of being restarted), my jupyter console, connected via jupyter console --existing, does not exit immediately. Instead, it keeps running unless I input something.

This behavior is problematic as ideally I would like to reconnect the console as soon as the kernel is restarted using a simple while loop in my shell.