Current implementation restores mode 5 on exit. This may not always be valid. Needs further investigation.