Can I finish my final exam (intermediate school leaving certificate) in the middle and leave or do I have to sit until the end?

Due to health issues, I can't really study for my final exam, but I'll still take it. But theoretically, can I get up and finish my exam if I choose? Or do I have to wait until the end anyway, even if I'm finished?