Login and timeout

This has nothing to do with DietPi scripts are functions. Behaviour should be same on RPi OS or other Debian systems. The agetty login process (which handles TTY logins) has a default timeout of 60 seconds of inactivity during login. If you take longer than 60 seconds to type the password (or nothing is typed at all), it times out and resets.

You can override the agetty timeout for the login prompt by creating a persistent boot-time configuration /etc/systemd/system/getty@tty1.service.d/override.conf where you can set an own timeout.