Reset modules_cached flag when database disconnects