Enabling the "use-system-keyboard-layout" ibus setting solved the
problem for me, as described in comment #23 in
https://bugs.launchpad.net/ubuntu/+source/indicator-
keyboard/+bug/1240198
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
I've been suffering from this issue almost at every shutdown since I
installed Ubuntu (first 12.04 then 12.10), it disappeared when I
switched to KDE a couple of weeks ago. The more the system is used, the
more likely is the issue to happen, but I was never been able to
reproduce it systematically.