to close the current space in macOS you need to do the following:
- swipe up with 3 fingers to display space dock
- hold option key to display close buttons
- move mouse pointer over close button and click
create a script that does all of that. and bind it to a hotkey