Invalid windows are now also removed after startup.

This was needed when previously stored sessions were restored. They
contained window handles which might no longer be considered valid after
program changes/new configurations.