Do not try to restore terminal in shutdown hook, as it causes exception. Shorten default keep alive interval.