Optimized the shutdown process

When closing Tiled it checks whether any maps need saving and it also
saves the currently selected layer and view position. In doing so it was
making each of the open maps "current" twice, which causes all the
panels to update and is generally much more work than actually needed.

Now making maps current is avoided except for the case where the user is
prompted about whether he wants to save any changes, to make sure the
context of the question is clear.

Tiled now shuts down instantly, even with many maps open. It can be a
little disturbing at first.
Lua plugin: Write out image layer properties

Closes #435