When program was being terminated with a modified card and the tab
selected did not contain the modified card, the program aborted.
If user attempted to close a card that was not being displayed in the
selected tab, the wrong card was saved.
This change fixes these bugs. Fixes bug #41.