Hello Jackqueline,
Have you considered using jenkins CLI for this? From the CLI doc:
java -jar jenkins-cli.jar -s http://localhost:8080/jenkins/ disconnect-node NAME [-m VAL]
Disconnects from a node.
NAME : Slave name, or empty string for master
-m VAL : Record the note about why you are disconnecting this node
However, this cannot be invoked directly as a build step - you can consider using a post-build script or a separate job (running on the master) for this that can be triggered with a delay automatically or using upstream/downstream projects.
Hope this helps.
Bye for now,
Gurusharan S.