The plan was to lock himself away from the world for 40 years to stop himself from losing his virginity and missing out on becoming a wizard, capable of magically making himself immortal.
The emperor's pursuit of immortality included engaging in sexual relations with young girls, of which he and Tao Zhongwen collected 960 for this purpose.