Flash is only a TM, rather than an HM, in Gens 4, 5, and 6. In all of these Gens, if Flash is forgotten while being used in the overworld, it will remain in effect as normal. It will only wear off when the player moves into a non-dark area; moving into another dark room within the cave will not cancel Flash, even if the Pokemon no longer remembers the move.
Source: tested in each Gen.