properly leave graphics mode on exit