Improve startup operation for commandline load and prevent exception when a file is closed and reopened without a UI restart.