I hope this information will be helpful to somebody.
There is a small bug in freeze rotation logic.
In the original code, we use simple rigidBody.freezeRotation. The problem is that this option work with all rotation constraints simultaneously and then you make it false. X and Y constraints eventually become false. As a result, sometimes a ship can rotate by X and Y.
To solve the problem I’ve written a simple method which replaced rigidBody.freezeRotation.
Eventually, my rotation code looks like this.