Chain the commands together?
Code:
netcat -l -p (myport) > backup.sql.gz && <close command>
The && ("and") will run the second command upon the successful completion and exit of the first (if exit status is 0). (Note that I don't know anything about using netcat, so can't add the exact command.)
You can even add on a || "or" option, in case the command fails (exit status >0).
Code:
netcat -l -p (myport) > backup.sql.gz && <close command> || <some other command>
===
Edit: I took a look at the netcat man page, and maybe I was wrong in my understanding. Am I right in understanding that the "listen" option doesn't exit? Well, I see that there is a -q "quit" option that will terminate the connection a set number of seconds after receiving an EOF. Would that do what you want?