I have no idea what else can help you, but you need to dive into Kernel#system coll, there are some parameters to fork processes, I thinki it can help you
Hm, can you check in terminal this command? Your shell comand have to release you terminal at least. Is it true (it releases) the issue is in another place.
.Are you sure all your shell commands are completed fast and don't delay the response? Can you add some sort of logging to see all lines are executed or some lne are't execited?
It seems "done" shoud be placed at the end of the do ... end block after all other stuff, so the block should return this value. HTTP header Connection=close is far enough from what you need.