implemention terminal initalisation and termination

Signed-off-by: Mattias Andrée <maandree@operamail.com>
misc

Signed-off-by: Mattias Andrée <maandree@operamail.com>