My Minecraft server doesn't work if the lid on my laptop is closed
Apple laptops of that vintage sleep when the clamshell is closed, suspending any processes, including your Minecraft server.
There are a few ways to keep Mac laptop from sleeping when you close the lid. However, note that the reason the default behaviour is to go to sleep is because the laptops are not engineered to properly deal with the heat of running programs while the lid is closed, so if you do use any of these hacks, be sure to keep a close eye on it to make sure Minecraft doesn't overheat it.