Ah... then you have to use unbuffered input, which is not provided by the standard libraries. This FAQ will show you several ways to get an unbuffered character. That way the program ends immediately after pressing 'a'.
Interestingly enough, with what you showed me, concerning something like "pdfjka ifhf" everything after 'a' isn't going to be processed anyway.
I hope I helped.