It is due to a certain kind of photosynthesis performed by this plant called CAM (Crassulasian Acid Metabolism). This is due to there is no kranz anatomy in their leaves. So, stomata opens only during night. For what, these plants have the ability to intake carbon dioxide during night. More similar to C4 plants. That's it !!
Not only Tulsi, there are few other plants like Peepal plant, orchid, Areca Palm, Neem tree, Aloe Vera etc. which release O2 during night.