Developing with my own plugin recently, I noticed receiving a suspicious 'switchin' called immediately after shutdown on application exit.  It was repeatable and completely testable.  I found that whatever plugin that was active on program exit would receive one little extra call to its switchin method immediately after the shutdown.  In most cases this is harmless, resulting only in allocation errors that are cleaned up on exit anyways, but if you happen to play an audio sample in the switchin LOOK OUT!

It looks to me as if there is a magic_switchin( canvas) call (see src/tuxpaint.c line 2704 in latest CVS) that is simply missing a guard against the mainloop exit initiated by the TOOL_QUIT section (line 2693).   Changing line 2704 to read
        if( !done) {
                magic_switchin( canvas);
        }

The above rule seems sufficient to me to correct the problem, but I welcome all comments or criticisms of my approach.

Thanks for a great application!

Sincerely,
Dan Shields