Hello,
I've just got back in from a quick come ride and checked my code.
I don't use B4XPages_Appear, that section of code is commented out, I use B4XPages_Foreground, but I don't close the database in B4XPage_Background, I close the database whenever it finishes it task, basically in the same sub.
In a few previous projects I have left the database open, but it completely depends on the project...