Fix the shutdown sequence for maemo, SDL and simulator builds