Fix various failures in recorded test cases

This pull request reintroduces the check for ```DynamoModel.IsTestMode``` that exists in [the previous version](https://github.com/Benglin/Dynamo/blob/fbbdfc21dec3f98fc082c2417d32069ef138499f/src/DynamoCore/UI/Views/DynamoView.xaml.cs#L614) of ```DynamoView.xaml.cs``` before the shutdown sequence code went in. The check was accidentally removed by the shutdown sequencing work.

Hi @lukechurch, please have a look and I'll cross-merge it into ```Revit 2015``` branch once that's done. It should stabilize the test results.