Why does my closed MacBook appear as online?

Why does my closed MacBook appear as online in my "My computers" list? I can also start logging in, but then I am kicked off and it goes back to offline in the list. A little while later it will appear as online again and after a while it will be offline and it does this all day long as long as the lid on my Macbook is closed. If I leave the lid open, it will stay online and I can access it like normal. My problem isn't that I want to be able to use it with the lid closed, but rather that I get notifications about it being available and I don't want it to sort off log on and then back off again. Is this perhaps a setting in MacOS and does anyone have an idea of what it is? I have switched off PowerNap which I thought could be the reason but that made no difference. Any help would be appreciated!