SQLite Forum

WAL/SHM files do not get deleted with ReadOnly flag
That would be a mistaken impression.  It would be perspicacious to keep track of whether a connection is open or not directly rather than by relying on magical signals from the gods.

Sometimes when a connection is closed it is sunny out, sometimes it is not.  Whether or not the sun is shining (like testing whether or not the WAL file exists) is not a recommended way to tell if a connection is open.