Raw mode fix

This pull request restores the terminal mode when the program exits (normally or by SIGINT).