regedit: add a panic handler to restore terminal