Safe as in only allow links, and only certain links. If you give people access to your run command your whole pc is in danger.

Well, you'd need a separate script to pull the length info from the YouTube link provided and set a variable active for that period of time.
Dunno how to close a tab, guess you'd have to script something for the registry editor and allow to close tabs from your default browser as well.