I have met the same issue and as result I had to review all solutions on this page and related one. No one is good for me. That is why I have made small research and it is appeared that problems with captured TCP port happen just because neither Gradle nor mvn knows nothing about child manipulation with TCP port.
So instead of killing process just use command:
$ gradlew –stop
(I hope the same exists for mvn
)
This command gracefully closes daemons started by Gradle and frees captured by Tomcat ports.