Make a representation before the higher authorities enclosing all the particulars of your service. Now, if they are not accepting your resignation on the ground that a case is pending against you, assure them that you will come as and when your presence is required. They cannot bar you from leaving the company on this ground alone.
Make a strong representation and if nothing positive is forthcoming, I suggest you file a case against them before the concerned High Court seeking direction against the railway authorities for accepting your resignation.