If any member withdraws from the retirement system prior to retirement the total amount contributed by him with such interest as may be credited thereto shall be returned to him; provided, however, that the board may prescribe the terms and conditions upon which a member, whose district service is terminated except by death or retirement, may elect to leave his contributions and interest thereon in the retirement fund, and the terms and conditions upon which a retirement allowance may be made to him after such termination based upon his contributions prior to such termination.