Tidier handling of main and sub-windows closing...  I think this finally
defeats the random SEGFAULT on exit once and for all...
Write a unit test for auditing that the history database matches the files
currently in the project directory.
Flush project history on closing a plugin so that users can't CTRL+Z away
their plugin edits.