Move the final closeSession() into a final try/catch statement

Drop the throw(err) approach as it does not work with command-line script
calling. Instead fill the value of the return code so that the examples can be
called as follows:
matlab -nodisplay -nosplash -nodesktop -r "script; exit(rc)"
merge dev_4_4 -D org -I include -E exclude: PR 988 (webgallery prototype from github/will-moore/webgallery)
merge dev_4_4 -D org -I include -E exclude: PR 1126 (Fix long-missing DELETE EventLogs)
merge dev_4_4 -D org -I include -E exclude: PR 1249 (Dataset creation 11048)
merge dev_4_4 -D org -I include -E exclude: PR 1321 (Insight connectors dev 4 4)
merge dev_4_4 -D org -I include -E exclude: PR 1409 (Python integration test fixes  and introduction of pytest)
merge dev_4_4 -D org -I include -E exclude: PR 1410 (First round of preparing Insight for UI testing)
merge dev_4_4 -D org -I include -E exclude: PR 1411 (Exit with non zero exit code if a Matlab training example fails)
merge dev_4_4 -D org -I include -E exclude: PR 1414 (Clean up components/common/test.)
merge dev_4_4 -D org -I include -E exclude: PR 1417 (Make JDK 1.6 the minimum supported version (dev_4_4))
merge dev_4_4 -D org -I include -E exclude

Repository: openmicroscopy/openmicroscopy
Already up-to-date.
Merged PRs:
  # PR 988 will-moore 'webgallery prototype from github/will-moore/webgallery'
  # PR 1126 joshmoore 'Fix long-missing DELETE EventLogs'
  # PR 1249 will-moore 'Dataset creation 11048'
  # PR 1321 jburel 'Insight connectors dev 4 4'
  # PR 1409 ximenesuk 'Python integration test fixes  and introduction of pytest'
  # PR 1410 mtbc 'First round of preparing Insight for UI testing'
  # PR 1411 sbesson 'Exit with non zero exit code if a Matlab training example fails'
  # PR 1414 bpindelski 'Clean up components/common/test.'
  # PR 1417 rleigh-dundee 'Make JDK 1.6 the minimum supported version (dev_4_4)'

Repository: openmicroscopy/bioformats
Already up-to-date.
Merged PRs:
  # PR 622 ctrueden 'Upgrade SLF4J to 1.7.2 [dev_4_4]'
  # PR 650 sbesson 'Java 1.7/Findbugs fixes (rebased onto dev_4_4)'
  # PR 653 rleigh-dundee 'Make JDK 1.6 the minimum supported version (dev_4_4)'

Repository: ome/scripts
Already up-to-date.

Repository: openmicroscopy/ome-documentation
Already up-to-date.
Merged PRs:
  # PR 368 rleigh-dundee 'Cpp: Correct content and markup'

Generated by OMERO-merge-stable#341 (http://hudson.openmicroscopy.org.uk/job/OMERO-merge-stable/341/)