The electric-field-induced quantum phase transition from topological to conventional insulator has been proposed as the basis of a topological field effect transistor1-4. In this scheme, 'on' is the ballistic flow of charge and spin along dissipationless edges of a two-dimensional quantum spin Hall insulator5-9, and 'off' is produced by applying an electric field that converts the exotic insulator to a conventional insulator with no conductive channels. Such a topological transistor is promising for low-energy logic circuits4, which would necessitate electric-field-switched materials with conventional and topological bandgaps much greater than the thermal energy at room temperature, substantially greater than proposed so far6-8. Topological Dirac semimetals are promising systems in which to look for topological field-effect switching, as they lie at the boundary between conventional and topological phases3,10-16. Here we use scanning tunnelling microscopy and spectroscopy and angle-resolved photoelectron spectroscopy to show that mono- and bilayer films of the topological Dirac semimetal3,17 Na3Bi are two-dimensional topological insulators with bulk bandgaps greater than 300 millielectronvolts owing to quantum confinement in the absence of electric field. On application of electric field by doping with potassium or by close approach of the scanning tunnelling microscope tip, the Stark effect completely closes the bandgap and re-opens it as a conventional gap of 90 millielectronvolts. The large bandgaps in both the conventional and quantum spin Hall phases, much greater than the thermal energy at room temperature (25 millielectronvolts), suggest that ultrathin Na3Bi is suitable for room-temperature topological transistor operation.