Add a keyboard lock: e.g. pressing "*" for a longer time locks a keyboard. The application then turns off the backlight and ignores any key press, except for unlock (e.g. the same "*" long press).
This would prevent accidental key press and track logging termination, or event application exit, when carrying mobile in pocket.