Rewrite timer communication to use a state machine and structs.
free() timer struct during cleanup.
Split thread shutdown notification / join.
Keep the main window open while waiting for shutdown.