It stays awake if you have an open connection (like sprite console) or an exec session if running and producing stdout.
You can specify a max exec time for a process when you launch it via the API.