Discharge application can be filed after filing final report or chargesheet the accused can file an application for discharge it is granted on basis or report submitted by police.
Section 239, Crpc when accused shall be discharged. - (1) If, upon considering the police report and the documents sent with it under Section 173 and making such examination, if any, of the accused as the Magistrate thinks necessary and after giving the prosecution and the accused an opportunity of being heard, the Magistrate considers the charge against the accused to be groundless, he shall discharge the accused, and record his reasons for so doing.
If discharge is not allowed you can prefer a quashing petition in high court the high court can stay investigation and proceeding and quash FIR.