Fixed a bug where the console mode was not properly retored.