Mendix addresses this issue here (look for the section on code lock-in). Be aware that the fact that it is possible does not mean it's effortless.
And see here the documentation about exporting and an example on github: https://docs.mendix.com/apidocs-mxsdk/mxsdk/use-case-examples#-exporting-your-apps
Regards,
Ronald