Avoid error message if --version flag is used. Closes #3914.