You cannot leave your planet entirely idle. If you have no more improvements to build or upgrade, you will have to select one of the planet projects. At that moment, any built up unused production will be discarded. My advice is "Don't do that!"
This is the one case I know of where you can actually lose production, otherwise, it always rolls over. Even if the last thing you build is a shipyard and you then go for Military Subsidies, you will lose that extra manufacturing and only ongoing manufacturing will go towards the project.
This also happens if you have a project ongoing and get a tech that enables an upgrade. If you have automatic upgrades enabled, the planet automatically schedules the upgrade, and then goes back to the project. Leftover production is not preserved when the planet switches back to the project. This also happens when you manually schedule the upgrade and switch back. Leftover production is not not preserved when you switch back to the project. Micromanaging won't help. 