There are several situations where having lights turn off automatically after a set time might be desirable. Like many of the automations in my home, the goal is to be more eco-friendly; and one of the most significant issues we have with a busy family is that lights get left on in hidden places — like closets.
You might be thinking that automatically turning off a light would be simple. But, unfortunately, that's not the case.
A device in HomeKit cannot be a trigger for controlling itself directly, nor can you set a wait period before another action is performed. Fortunately, you can solve both these problems by telling HomeKit to run a Shortcut instead.
When Coat Closet light turns on
Run Shortcut
This Shortcut, in turn, will contain the following Actions:

To run a Shortcut from a Home Automation, create a Home Automation like normal. However, when choosing the Actions to perform, scroll to the very bottom of the list, and under "Advanced," choose "Convert to Shortcut":



Within the Set action, you will then set the same device from the trigger to turn off:

Tap "Done," and you're finished. Now the light will automatically turn off 300 seconds — five minutes — after it turns on.