A metaphorical police force imagined to prevent others from having fun.
Someone who puts an end to others' fun, especially harmless fun.
Like a spoilsport.