Is writing a grant proposal at the end of Ph.D. a good idea?
Writing grant proposals with your supervisors is great experience and good for your career.  Writing in partnership with more experienced researchers is a great to to get "apprenticeship" experience and to become introduced to key funding agencies, program managers, and the expectations and practices in interacting with them.  Moreover, even if you move on before the grant is funded, you may find yourself able to work on the project via a subcontract to your new institution or else to help supervise students on the project from afar (I certainly had this experience).  

Thus, if there is a good opportunity for doing collaborating with your supervisors on grant-writing, I highly advise doing so.