Bug 1039943: make gallery exit if it goes to background while scanning o...

...n a 256mb device or smaller

(cherry picked from commit bddd3a639ccf6353d06ae215215c4a4ddd31cffa)