Updated stty session state save to check for an interactive terminal - this prevents stty throwing errors in the output when run in a non-interactive session.