Description: Reset terminal state on exit
 After endwin() and e_switch_screen(), the terminal may still be left in
 a bad state (no echo, invisible cursor, wrong character set) because
 ncurses endwin() output goes through stdout which may be buffered.
 Explicitly restore termios settings and send a full terminal reset via
 stderr to ensure the terminal is usable after wpe exits.
Author: Juan Manuel Méndez Rey <juan.mendezr@proton.me>
Last-Update: 2026-05-25

diff --git a/we_unix.c b/we_unix.c
index bf0eaa4..420ee82 100644
--- a/we_unix.c
+++ b/we_unix.c
@@ -379,6 +379,8 @@ void e_exit(int n)
 #endif
  (*WpeDisplayEnd)();
  e_switch_screen(0);
+ tcsetattr(0, TCSADRAIN, &otermio);
+ fputs("\033c", stderr);
  if (n != 0)
  {
   printf("\nError-Exit!   Code: %d!\n", n);
