Motion sensor + light = light stuck sometimes

Thank you for all the replies and help!

Andrews way of solving the problem felt a little complicated since there already is a counter.
I did some more digging and solved the problem by using an input boolean.
Thanks to this thread: