Rewrote the function that closes tabs so that it is more functional.

The close tab function now handles figuring out what tabs to close properly, so that pinned tabs aren't even considered, and locked, unexpired, and active tabs cannot be closed (but are still considered).  Tabs also close in the order that they were accessed.