$!
The PID of the last process sent to the background.
When a command departs with &, the shell keeps its PID in $!. It is the leash of the loose process: wait $! waits for it, kill $! ends it.
Each new & overwrites the value — whoever launches several processes writes the PIDs down as they go, one by one, before the next flight.
$ ./monitorar-ninho.sh &
[1] 27182
$ echo $!
27182
$ wait $!